Join the community today
Become a Member

Nginx NGINX WebSockets Performance

Discussion in 'Nginx and PHP-FPM news & discussions' started by eva2000, Jun 25, 2014.

Tags:
  1. eva2000

    eva2000 Administrator Staff Member

    27,774
    6,336
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,339
    Local Time:
    3:24 PM
    Nginx 1.13.x
    MariaDB 5.5
    We recently tested the scalability of NGINX to load-balance WebSockets connections. Even with 50,000 active web socket connections, NGINX required less than 1 Gb memory and less than one core of CPU capacity, and when loaded up with very busy connections, memory usage was stable and increased more slowly than message size. The performance you will see in your environment will depend on the nature of your application, but the results of these tests can provide some indication of the type of resources you can expect to be used by NGINX.

    Test Environment


    The following machines were used for this testing:

    Load generator: thor was used on a 6 core Xeon EX5645 @ 2.40GHz, 48GB RAM​

    NGINX: Version 1.7.0, x86_64 with 6 workers on a 6 core Xeon E5645 @ 2.40GHz, 48GB RAM​

    WebSockets backend: node.js echo server on a 4 core Xeon E5-2660 0 @ 2.20GHz, 8GB RAM​

    Tests


    Two sets of test were run. The first set of tests simulates long lived and mostly idle connections. The number of connections was varied from 1,000 to 50,000, the size of the messages from 10 to 4096 bytes and the frequency of messages was low, between 0.1 and 10 seconds. The results show that the total memory utilized to handle Websockets is dependent on the number of connections and that the memory used per connection is consistent. Memory utilization is not impacted by message size or frequency. CPU utilization basically trends with the number of connections and even at 50,000 connections did not utilize a full CPU core. The CPU utilization represented here is normalized to a single core by adding up the CPU utilization across all the cores. The following graphs show the results for this set of tests:

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    The second set of tests simulate short lived but highly active connections. The number of concurrent connections was kept constant at 500, with 50 messages per connections and without a delay between messages. The message was varied from 1 to 4096 bytes. The results of these tests show that with the number concurrent connections at a fixed value, the total memory utilization is a factor of the message size, as is the memory used per connection, but in both cases the amount of memory does not vary much and varies in a sub-linear manner, increasing by less then 15%.

    [​IMG] [​IMG]

    [​IMG] [​IMG]

    Summary


    During these tests, NGINX delivered predicable and scalable performance when proxying WebSocket servers. These were synthetic tests and not necessarily representative of a real world application, so the results of tests done on other systems may differ. For more information please see: NGINX as a WebSockets Proxy Using NGINX with WebSockets NGINX documentation NGINX and NGINX Plus features NGINX Plus Technical Specifications

    The post NGINX WebSockets Performance appeared first on NGINX.

    Continue reading...