Implementing Pixel Streaming with Unreal Engine on AWS: A Step-by-Step Guide

Implementing Pixel Streaming with Unreal Engine on AWS: A Step-by-Step Guide

Implementing Pixel Streaming with Unreal Engine on AWS: A Step-by-Step Guide

#GameDev

#GameDev

#GameDev

Marketing & Growth

Published on November 13, 2024

Published on November 13, 2024

Published on November 13, 2024

Table of Contents

In today's digital landscape, delivering high-fidelity, interactive experiences to users across various devices is paramount. Unreal Engine's Pixel Streaming, when deployed on Amazon Web Services (AWS), offers a robust solution to this challenge. By running applications on remote servers and streaming rendered content directly to users' web browsers via WebRTC, Pixel Streaming ensures seamless interactivity without the need for powerful local hardware. This approach is particularly advantageous for applications such as architectural visualizations, product configurators, and immersive games.

Key Benefits of Pixel Streaming:

  • Device Independence: Users can access high-quality applications without relying on high-end local hardware.

  • Simplified Distribution: Applications are accessible via web browsers, eliminating the need for complex installations.

  • Centralized Updates: Updates are applied on the server side, ensuring all users have access to the latest version without manual intervention.

By leveraging AWS's scalable infrastructure, developers can efficiently deploy Unreal Engine applications using Pixel Streaming, delivering rich, interactive content to a broad audience with minimal client-side requirements.

Alternatively, Vagon Streams simplifies this process, allowing you to start streaming your content to thousands of users within seconds. With RTX-enabled NVIDIA GPUs and worldwide coverage through 21 data centers, Vagon Streams delivers low-latency, high-performance streaming without the hassle of intricate setups.

AWS Services for Pixel Streaming: A Comprehensive Guide

Setting up Pixel Streaming for Unreal Engine applications on AWS requires a blend of AWS services that streamline deployment, provide the necessary computing power, and ensure scalability. Let’s dive into the key AWS services that facilitate Pixel Streaming and how you can use them to start deploying your application seamlessly.

Amazon EC2 G4 Instances

What It Is: Amazon EC2 G4 Instances are GPU-powered virtual machines designed specifically for graphics-intensive workloads. They are well-suited for hosting Unreal Engine applications that require substantial GPU resources to deliver high-quality, interactive experiences.

Why It’s Essential for Pixel Streaming:

  • High-Performance Graphics: G4 instances come equipped with NVIDIA T4 GPUs, capable of rendering complex 3D graphics at high resolutions, essential for running Unreal Engine applications at optimal performance.

  • Supports Multiple Users: These instances can handle concurrent users, ensuring your application remains responsive and high-quality even under load.

Getting Started:

  • Instance Type: Start with the g4dn.xlarge instance, which provides a good balance of cost and performance. You can scale up to larger G4 instances as your user base grows.

  • Operating System: Unreal Engine Pixel Streaming typically requires Windows for the host server, so choose a Windows Server AMI when launching your instance.

  • Security Groups: Set up security groups to manage network traffic, allowing access to the necessary ports for Pixel Streaming (usually port 80 for HTTP and 8888 for the signaling server).

Amazon S3 (Simple Storage Service)

What It Is: Amazon S3 is AWS's scalable object storage service. It’s ideal for storing and distributing large files, such as Unreal Engine builds, configuration files, and asset packages.

Why It’s Essential for Pixel Streaming:

  • Easy Distribution: S3 allows you to store your Unreal Engine build and access it from anywhere, streamlining the process of deploying updates.

  • Reliability: S3 ensures durability and accessibility, so you can rely on it to distribute your assets quickly and efficiently.

Getting Started:

  • Create an S3 Bucket: Set up a new bucket to store your Unreal Engine application build. You may want to use versioning to track changes and manage updates.

  • Organize Files: Store your main build file and any additional assets or configuration files in clearly labeled folders. This organization will make it easier to access specific components when deploying or updating.

  • Permissions: Control access to your bucket with AWS Identity and Access Management (IAM) roles to ensure only authorized users and instances can access your assets.

AWS CloudFormation

What It Is: AWS CloudFormation is a service that automates the setup and configuration of AWS resources through predefined templates. This is invaluable for creating a consistent infrastructure setup, especially for complex deployments like Pixel Streaming.

Why It’s Essential for Pixel Streaming:

  • Automated Setup: CloudFormation allows you to quickly deploy the necessary infrastructure, including EC2 instances, security groups, and other resources, using a template.

  • Repeatable and Consistent: Using a CloudFormation template ensures that you can redeploy or scale your infrastructure in a repeatable and consistent way, reducing the risk of configuration errors.

Getting Started:

  • Create a CloudFormation Template: Use or customize a template specifically for Pixel Streaming, which should include configurations for EC2 instances, VPC, security groups, and any other essential components.

  • Launch the Stack: Deploy your CloudFormation stack to automatically provision your resources. You can scale your resources as needed by adjusting the template and redeploying.

  • Monitor and Manage: CloudFormation makes it easy to manage and update your infrastructure, ensuring a smooth scaling process when traffic increases.

With the essential AWS services in place, you’re ready to move into the deployment phase for Pixel Streaming on AWS. Each step in this process is crucial for setting up a scalable and reliable streaming environment. From configuring the Unreal Engine application to managing AWS infrastructure and implementing the streaming components, these deployment steps will guide you through establishing a robust setup that allows your application to reach users seamlessly through their browsers. Let’s dive into the details of deploying your Pixel Streaming application.

1. Prepare the Unreal Engine Application

To get started, you need to make sure that your Unreal Engine application is optimized and packaged for Pixel Streaming. This step ensures that the application can render high-quality graphics and transmit them to remote users without latency issues.

  • Enable the Pixel Streaming Plugin:

    • Open your Unreal Engine project and navigate to Edit > Plugins.

    • Search for Pixel Streaming in the Plugins menu, and enable it. This plugin is essential as it handles the necessary streaming components, converting the application into a streamable format for WebRTC.

    • Unreal Engine may require a restart after enabling the plugin, so restart if prompted to activate all settings.

  • Optimize Streaming Settings:

    • After the plugin is enabled, go to Edit > Project Settings > Pixel Streaming. Here, you can adjust settings such as resolution (e.g., 1080p or 4K), bitrate (e.g., 10,000 kbps for high quality), and frame rate to find a balance between visual quality and streaming performance.

    • Set interactive input controls to allow real-time user actions like clicks or drags, which are essential for immersive experiences.

  • Package the Build:

    • Once configured, it’s time to package the application. Choose File > Package Project, and select the target platform (typically Windows for AWS EC2 instances).

    • Ensure that you select a shipping build configuration to optimize performance and reduce any debug overhead, producing a stable and efficient version for live streaming.

  • Testing the Build Locally:

    • Run the build locally on your machine to verify that the Pixel Streaming setup works as expected before uploading to AWS. Confirm that streaming quality, responsiveness, and input functionality meet your requirements.

2. Set Up AWS Infrastructure

AWS provides the computing resources necessary to host and scale Pixel Streaming applications. Setting up an EC2 instance with GPU support is essential for handling the real-time rendering demands of Unreal Engine.

A. Launch EC2 Instances

The core processing for Pixel Streaming will happen on an Amazon EC2 instance, particularly the G4 instance type, which is optimized for high-performance graphical workloads.

  • Instance Selection and Configuration:

    • Go to the EC2 Dashboard on AWS and click on Launch Instance.

    • Choose the g4dn.xlarge instance type, which offers NVIDIA T4 GPUs, giving it the power needed to render high-fidelity graphics for Unreal Engine. This instance type is cost-effective for moderate workloads and can handle multiple concurrent users.

    • Select a Windows Server 2019 or 2022 AMI (Amazon Machine Image) since the Pixel Streaming plugin requires Windows for deployment. AWS also provides pre-configured Amazon Machine Images (AMIs) that have necessary GPU drivers.

  • Instance Configuration:

    • Storage: Allocate sufficient storage based on your project’s size. Unreal Engine projects can be large, so you may need 100 GB or more for storage.

    • Network Settings: Enable a static public IP for the instance to provide consistent access for users and connect the instance to the internet gateway.

    • IAM Role: Attach an IAM role with permissions to access other AWS services, like S3, which will be used to transfer the application.

  • Launch the Instance and GPU Driver Installation:

    • Launch the instance and connect via Remote Desktop Protocol (RDP) using the downloaded key pair.

    • After connecting, install the NVIDIA T4 GPU drivers on the instance. AWS provides a guide to install the drivers, or you can download them directly from the NVIDIA website.

B. Configure Security Groups

Security groups control access to your EC2 instance and help secure your application.

  • Create a Security Group:

    • Define a new security group to manage incoming and outgoing traffic. Allow HTTP (port 80) and HTTPS (port 443) traffic if users access the application over the web.

    • Allow port 8888 or your configured signaling port for Pixel Streaming.

    • Limit access to specific IPs if necessary for development and testing.

  • Attach the Security Group:

    • Associate the security group with your EC2 instance during or after setup to control traffic effectively and enhance security.

3. Deploy the Application

With the infrastructure ready, you can now deploy the application files and set up Pixel Streaming.

A. Upload to Amazon S3

Using Amazon S3 provides an efficient way to store and transfer large application files, especially for frequent updates.

  • Create an S3 Bucket:

    • Go to the S3 Dashboard and create a new bucket where you’ll store your Unreal Engine packaged build.

    • Enable versioning on the bucket if you plan to update or manage multiple versions of the application. This allows for organized updates and rollbacks if needed.

  • Upload Build Files:

    • Upload the entire build package (application files, assets, and configurations) to S3.

    • Ensure permissions allow the EC2 instance to access and download files from the bucket. You can set this up using IAM roles to grant access only to the resources that need it.

B. Install on EC2

Now that the build is stored on S3, it’s time to transfer it to your EC2 instance and configure it for streaming.

  • Connect to the EC2 Instance:

    • Use RDP to connect to the instance, then install any remaining prerequisites for running the Unreal Engine application.

    • Use AWS CLI commands or a script to download the build from S3 directly onto the EC2 instance, saving time on file transfers.

  • Install Necessary Dependencies:

    • Ensure DirectX, Visual C++ Redistributables, and any Unreal Engine prerequisites are installed on the EC2 instance.

    • Verify that all dependencies required by Pixel Streaming are up-to-date to avoid runtime issues.

  • Launch the Application:

    • Start the application in Pixel Streaming mode using the command prompt, e.g., YourApp.exe -PixelStreamingIP=YourInstanceIP -PixelStreamingPort=8888.

    • Verify that the application runs smoothly on the EC2 instance and is ready to accept client connections.

4. Configure Pixel Streaming Components

Pixel Streaming requires additional servers to manage client-server interactions and improve connectivity for users behind strict firewalls or NATs.

A. Signaling Server

The signaling server manages WebRTC connections between your Unreal Engine application and client browsers.

  • Install Node.js:

    • Connect to the EC2 instance or a separate machine for the signaling server and install Node.js, required to run the signaling server.

  • Set Up and Start the Signaling Server:

    • Locate the signaling server code within the Unreal Engine Pixel Streaming plugin directory.

    • Use the command node your-signaling-server.js -port 8888 (or other configuration) to start the server.

    • Configure signaling server parameters to manage multiple users, customize bandwidth, and ensure connections are routed correctly.

B. TURN Server

A TURN server is essential for applications where users may be behind NATs or firewalls, as it routes media through relays.

  • Set Up a TURN Server:

    • You can install coturn on another EC2 instance as a TURN server.

    • Configure the TURN server with necessary credentials and SSL certificates for secure connections.

    • Specify network settings to allow access through common NAT and firewall configurations.

  • Integrate with the Signaling Server:

    • Modify your signaling server configuration to include TURN server details, specifying TURN and STUN options as fallback options for WebRTC connections.

With your Pixel Streaming application successfully deployed and configured, the next focus is on ensuring it can handle varying levels of user demand. By implementing scaling strategies, you’ll be able to maintain optimal performance during traffic spikes and maximize resource efficiency during quieter periods. Additionally, establishing load balancing and automated scaling will help deliver a consistently smooth experience for users, even as demand fluctuates. Let’s explore how to set up these essential scaling features for a resilient and responsive application.

Scaling Considerations

When deploying Unreal Engine applications with Pixel Streaming, scaling is crucial to accommodate fluctuations in user traffic and to maintain performance. Here are strategies to implement effective scaling:

1. Auto Scaling Groups (ASG)

Auto Scaling Groups allow AWS to automatically adjust the number of EC2 instances in response to real-time demand, maintaining performance and optimizing costs.

  • Setting Up Auto Scaling Groups:

    • Navigate to the EC2 Dashboard and select Auto Scaling Groups.

    • Configure the ASG to launch the same instance type used for your Pixel Streaming application (e.g., g4dn.xlarge).

    • Define minimum, maximum, and desired instance counts based on your application’s expected traffic. For example, set a minimum of one instance for low-traffic periods and a higher maximum for peak times.

  • Defining Scaling Policies:

    • AWS offers various scaling policies, including target tracking, step scaling, and simple scaling.

    • Target tracking scaling is generally preferred for Pixel Streaming as it automatically adjusts the number of instances based on a specific metric, such as CPU utilization. For example, you might configure the ASG to maintain CPU utilization at around 70%.

    • Alternatively, you can set up step scaling based on traffic or session count. For instance, if you reach 80% CPU usage, the ASG could add one additional instance, and add two instances if it hits 90%.

  • Monitoring and Adjusting:

    • Use Amazon CloudWatch to monitor metrics like CPU utilization, network traffic, and GPU usage.

    • Adjust your scaling policies based on observed performance trends. If traffic peaks consistently at certain times, consider setting scheduled scaling actions to add instances during these times.

2. Elastic Load Balancing (ELB)

To efficiently distribute incoming traffic, an Elastic Load Balancer (ELB) can route users to the best-performing instance, reducing latency and enhancing reliability.

  • Setting Up an Application Load Balancer (ALB):

    • In the EC2 Console, select Load Balancers and create an Application Load Balancer (ALB).

    • Choose Internet-facing as the load balancer scheme, ensuring that users can access the application externally.

    • Define the listener configuration for HTTP and HTTPS traffic, depending on your security requirements.

    • Associate the load balancer with the Auto Scaling Group you previously configured.

  • Configure Target Groups:

    • A target group specifies which EC2 instances should receive traffic. Assign your EC2 instances to a target group, and configure health checks for these instances.

    • Health checks can be set up to ping the signaling server or main application port (e.g., 8888) to ensure instances are functioning correctly. If an instance fails the health check, the ALB will automatically redirect traffic to healthy instances.

  • Session Persistence (Sticky Sessions):

    • For Pixel Streaming, enabling sticky sessions (session persistence) ensures that each user remains connected to the same instance for a seamless experience.

    • Configure sticky sessions within the ALB settings to maintain consistent performance during the user’s session.

  • Scaling with Load Balancers:

    • The ALB also assists with scaling by rerouting traffic during periods of high load, reducing bottlenecks, and preventing any single instance from being overwhelmed.

Experience Vagon Streams Now!

Setting up Pixel Streaming on Amazon requires navigating various technical configurations, from choosing the appropriate GPU-optimized virtual machines to setting up secure networking and managing scaling to handle user demand. Each step demands careful planning and execution to ensure the best performance and robust security.

For those looking for a more streamlined solution, Vagon Streams offers a fast alternative, enabling you to broadcast your content to thousands of users almost instantly. Equipped with RTX-enabled NVIDIA GPUs and a network of 21 data centers worldwide, Vagon Streams delivers top-tier streaming performance with minimal latency, all without the complexity of traditional cloud setups.

Just login, upload your application and configure your preferences — and you're good to go!

Scalable Pixel and Application Streaming

Run your Unity or Unreal Engine application on any device, share with your clients in minutes, with no coding.

Scalable Pixel and Application Streaming

Run your Unity or Unreal Engine application on any device, share with your clients in minutes, with no coding.

Ready to focus on your creativity?

Vagon gives you the ability to create & render projects, collaborate, and stream applications with the power of the best hardware.