Skip to content

Can t4g.medium handle 500 concurrent WebSocket connections (50 per second per client) without performance issues?

0

Hello I have a WebSocket server running on an AWS EC2 t4g.medium instance (2 vCPUs, 4 GiB RAM). The setup involves 10 clients, each maintaining 50 WebSocket connections (total of 500 connections). Each connection sends a small message (price and timestamp) every second, for example : {"x":100, "t":1677832}. Can this instance handle the load efficiently, or should I consider upgrading?

1 Answer
1
Accepted Answer

Based on the information provided about your setup and the specifications of the t4g.medium instance, it should be able to handle 500 concurrent WebSocket connections without significant performance issues. However, there are a few factors to consider:

  1. Instance Capacity: The t4g.medium instance has 2 vCPUs and 4 GiB of memory, which should be sufficient for managing 500 WebSocket connections, especially given the small size of the messages being sent.

  2. Baseline Performance: The t4g.medium instance provides a baseline performance of 20% of a vCPU, which means it can sustain a moderate level of CPU usage without incurring additional charges.

  3. Burstable Performance: T4g instances are burstable, meaning they can temporarily use more CPU resources when needed. The t4g.medium earns 24 CPU credits per hour, which can be used for periods of higher activity.

  4. Network Performance: The t4g.medium instance can support network burst bandwidth of up to 5 Gbps, which should be more than enough for handling the small messages you're sending every second.

  5. Connection Limits: While some AWS services have specific limits on WebSocket connections, EC2 instances don't have a predefined limit. The limit is more dependent on the resources available and the efficiency of your application.

Given that you're sending small messages (price and timestamp) every second, the load on the instance should be manageable. However, to ensure optimal performance, you should monitor your instance's CPU utilization, network performance, and memory usage. If you consistently see high resource utilization or if you plan to scale beyond 500 connections in the future, you might want to consider upgrading to a larger instance type.

Keep in mind that while the t4g.medium should handle this load, the performance might degrade if your application has other resource-intensive tasks running alongside the WebSocket server. In such cases, you may need to upgrade to a larger instance or consider using a dedicated instance for your WebSocket server.
Sources
Amazon EC2 T4g Instances - Amazon Web Services

answered 9 months ago
AWS
EXPERT
reviewed 9 months ago
EXPERT
reviewed 9 months ago
  • Thank you for your detailed answer! Your insights on the t4g.medium instance capacity were really helpful.

    Following up on that, I wanted to ask: If I scale the setup to 20 clients with 100 WebSocket connections each (totaling 2000 concurrent connections), would the t4g.medium instance still be sufficient?

    In your experience, at what point would it be more efficient to upgrade to a larger instance, like t4g.large with 4 vCPUs? Are there specific metrics (like CPU utilization or network throughput) I should monitor to make the decision to upgrade?

    I appreciate it

  • Very dependent on the CPU, network and disk I/O that a connection generates. Having 100 open connections that do very little is no big deal, on the other hand if those connections are pushing data and causing CPU and disk I/O it will be very dependent on those details. Ultimately, you will need to test you application with (simulated) user activity to determine actual utilization driven on the instance.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.