Notebook · Notebook without plots · Python · Python without plots
Model a streaming service with a service builder
Use a VideoStreaming service when you want to describe
viewing sessions through resolution and duration, with delivery assumptions that
translate them into server resources. Use an ordinary Job for CPU work whose
resource needs you want to specify directly. Work outside delivery needs its
own model.
The worked example combines viewing and uploading in one user journey. We will connect the service to its server, create a streaming job, add demand, then inspect the resource estimates and the resulting footprint.
Load the scenario in the interface.
Install efootprint to run the Python cells.
from efootprint.abstract_modeling_classes.source_objects import SourceObject, SourceValue
from efootprint.builders.services.video_streaming import VideoStreaming, VideoStreamingJob
from efootprint.builders.timeseries import ExplainableHourlyQuantitiesFromFormInputs
from efootprint.constants.countries import Countries
from efootprint.constants.sources import Sources
from efootprint.constants.units import u
from efootprint.core.hardware.device import Device
from efootprint.core.hardware.network import Network
from efootprint.core.hardware.server import Server
from efootprint.core.hardware.server_base import ServerTypes
from efootprint.core.hardware.storage import Storage
from efootprint.core.system import System
from efootprint.core.usage.job import Job
from efootprint.core.usage.usage_journey import UsageJourney
from efootprint.core.usage.usage_journey_step import UsageJourneyStep
from efootprint.core.usage.usage_pattern import UsagePattern
Install the service and create its job
First describe the host with Server and its attached storage. The server still
supplies the capacity, provisioning and environmental assumptions: the streaming
service does not choose those for you. Here autoscaling provisions whole server
instances as demand requires them.
Attach VideoStreaming to that server through server=server. It holds the
shared delivery coefficients, so several jobs can reuse the same service with
different resolutions or durations. .from_defaults() fills in coefficients
we have not supplied; treat these as hypotheses to check against your platform.
storage = Storage.hdd()
server = Server.from_defaults(
"Streaming server", server_type=ServerTypes.autoscaling(), storage=storage,
power_usage_effectiveness=SourceValue(1.2 * u.dimensionless, Sources.HYPOTHESIS),
average_carbon_intensity=SourceValue(100 * u.g / u.kWh, Sources.HYPOTHESIS),
utilization_rate=SourceValue(0.9 * u.dimensionless, Sources.HYPOTHESIS),
base_ram_consumption=SourceValue(300 * u.MB_ram, Sources.HYPOTHESIS),
base_compute_consumption=SourceValue(2 * u.cpu_core, Sources.HYPOTHESIS))
video_streaming_service = VideoStreaming.from_defaults("Video streaming service", server=server)
Describe one viewing session
A VideoStreamingJob links to the service, which supplies
its server automatically. Its resolution label includes pixel dimensions; the
builder uses them with bits_per_pixel and refresh_rate to estimate bitrate.
That bitrate times video duration gives transferred data. The service's
static_delivery_cpu_cost converts bitrate into CPU need, while
ram_buffer_per_user supplies the RAM held for one concurrent viewer.
This is a delivery estimate based on those coefficients. It does not derive encoding or transcoding work from the resolution. Measure or source the coefficients for the delivery path you are assessing.
streaming_job = VideoStreamingJob.from_defaults(
"Watch 20 minutes", service=video_streaming_service,
resolution=SourceObject("1080p (1920 x 1080)"), video_duration=SourceValue(20 * u.min))
Add upload work separately
Uploading is a different operation, so describe it with a regular Job on the
same server. Its transferred payload and net stored data are separate inputs.
Viewing a video need not create another stored copy on the server; a new upload
can add to the library.
Using the same server keeps the infrastructure shared. Keep the service's extra base RAM separate from server-wide background needs: the model adds them, so the same measured overhead should not be entered in both places.
video_upload_job = Job(
"Upload captured video", server=server,
data_transferred=SourceValue(20 * u.MB, Sources.USER_DATA),
data_stored=SourceValue(20 * u.MB_stored, Sources.USER_DATA),
request_duration=SourceValue(2 * u.s, Sources.HYPOTHESIS),
compute_needed=SourceValue(1 * u.cpu_core, Sources.HYPOTHESIS),
ram_needed=SourceValue(50 * u.MB_ram, Sources.HYPOTHESIS))
Connect the operations to a user session
Put each operation in a UsageJourneyStep, then collect the steps in a journey.
The job's duration describes work on the server. user_time_spent describes how
long the user's device is in use, which can include time beyond the server job,
such as preparing an upload.
For uninterrupted viewing, keep video_duration and the viewing step's
user_time_spent consistent when changing the example. They are separate
inputs; changing the video duration does not update the device-use assumption.
streaming_step = UsageJourneyStep(
"20 min streaming", user_time_spent=SourceValue(20 * u.min, Sources.USER_DATA), jobs=[streaming_job])
upload_step = UsageJourneyStep(
"Capture then upload", user_time_spent=SourceValue(70 * u.s, Sources.USER_DATA), jobs=[video_upload_job])
user_journey = UsageJourney("Streaming and upload journey", uj_steps=[streaming_step, upload_step])
Project editable demand
A UsagePattern adds session starts, a viewing device, a network and a country
to the journey. Each occurrence in this example includes both a view and an
upload. Make sure that unit matches the demand you supply; if uploads occur at
a different frequency, their activity needs a different representation.
Supply new session starts rather than concurrent viewer counts. The model uses the jobs' durations to derive overlapping work and resource demand. Multiplying per-session resources by viewers yourself would apply the volume twice.
The demand builder smooths away daily and seasonal peaks, which limits what the example tells us about peak capacity. Adjust the projection to your service; use an hourly profile that represents those variations when peak sizing matters.
usage_pattern = UsagePattern(
"Streaming viewers in France", usage_journeys=[user_journey], devices=[Device.laptop()],
network=Network("Streaming Wi-Fi", bandwidth_energy_intensity=SourceValue(
0.05 * u.kWh / u.GB, Sources.TRAFICOM_STUDY)), country=Countries.FRANCE(),
hourly_occurrences=ExplainableHourlyQuantitiesFromFormInputs({
"start_date": "2025-01-01", "modeling_duration_value": 3,
"modeling_duration_unit": "year", "initial_volume": 43800000,
"initial_volume_timespan": "year", "net_growth_rate_in_percentage": 170,
"net_growth_rate_timespan": "year",
}, source=Sources.HYPOTHESIS))
system = System("Video streaming service system", [usage_pattern], edge_usage_patterns=[])
Inspect derived resources
Check the intermediate resource estimates before interpreting the footprint.
dynamic_bitrate is a rate for the chosen stream profile; data_transferred is
the amount for one session. CPU is the need for one concurrent stream, while RAM
comes from the service's per-viewer buffer assumption.
Changing resolution or frame rate changes the bitrate, data and CPU estimates. A longer video increases transferred data and occupied time without increasing the bitrate or instantaneous CPU need for the same profile. RAM per stream remains fixed unless you change the buffer assumption.
The period total includes the upload, user device, network and storage as well as streaming-server work. It is not the footprint of one video. The web tutorial shows how to attribute that total, and the export lesson covers files and comparisons.
print("Dynamic bitrate:", streaming_job.dynamic_bitrate.display_quantity)
print("Data per session:", streaming_job.data_transferred.display_quantity)
print("CPU per concurrent stream:", streaming_job.compute_needed.display_quantity)
print("RAM per concurrent stream:", streaming_job.ram_needed.display_quantity)
print("Period total:", system.total_footprint.sum().display_quantity)
2026-12-01 12:18:21,826 - INFO - Imported BoaviztaCloudServer in 0.03094 seconds.
Dynamic bitrate: 0.778 megabyte / second
Data per session: 933.0 megabyte
CPU per concurrent stream: 0.00311 cpu_core
RAM per concurrent stream: 50.0 megabyte_ram
Period total: 3.24 kilometric_ton
Pitfalls
- Treating a resolution as measured bitrate. Compression, frame rate,
content and adaptive delivery affect traffic. Here
dynamic_bitrateis one estimate for a chosen profile, rather than a time-varying bitrate trace. - Multiplying by the audience twice. Resource and data inputs describe one stream or operation; usage demand supplies repetition and concurrency.
- Confusing transfer with storage growth. Streamed bytes are network traffic. Use the storage baseline for the existing library and net per-operation growth for new data, with retention appropriate to your deployment.
- Assuming the whole video pipeline is covered. Capture, production and transcoding may need additional workloads when they belong to the assessment.
- Copying per-viewer costs into service overhead. The service's base needs are shared standing resource use; buffers belong to concurrent streams. Creating another service object per viewer would duplicate that overhead.