Elastic optical networks (EON) provide an adequate solution for flexible connections using a flexible grid (flex-grid) to manage resource availability and support high-bandwidth applications. However, EON resource utilization and QoS provisions are affected by dynamic traffic with variable parameters and needs created by new applications and services. This paper presents a flexible QoS scheme using optimized slice assignment to resolve traffic dynamism challenges. That scheme balances wavelength slice allocation and irregular traffic rates, integrating real-time and required parameters employing the designed slots' cost optimization. It enables an innovative cost formulation, developed in the mathematical model, to ensure EON constancy in supervising bandwidth essential granularity and variable traffic demands and improve loss, blocking probability, slice utilization, and extra mean processing time. Extensive simulation shows that the suggested scheme performs a novel algorithm, optimizing slice usage and guaranteeing traffic requirements better than the recent approaches, including arrival time and priority level of incoming variable traffic constraints.