• # nginx / openresty

    Posté par . En réponse au journal Le taptempo du web. Évalué à 3. Dernière modification le 15 juin 2022 à 13:31.

    Avec nginx / openresty (il faut openresty pour pouvoir générer la valeur aléatoire avec la commande set_random)

    worker_processes auto;
    worker_rlimit_nofile 100000;
    error_log logs/error.log crit;
    events {
     use epoll;
     multi_accept on;
     worker_connections 4000;
    }
    http {
     access_log /dev/null;
     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;
     gzip off;
     server {
     listen 6666;
     error_page 302 @30x;
     location @30x {
     default_type "";
     return 300;
     }
     location / {
     set_random $rid 1 21;
     rewrite ^/*$ https://avatar.spacefox.fr/Renard-${rid}.png redirect;
     }
     }
    }

    Commande: openresty -p "$PWD" -c ./nginx.conf

    ps aux:

    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    user 114966 0.0 0.0 11500 1320 ? Ss 12:35 0:00 nginx: master process
    user 114967 0.0 0.0 13164 4068 ? S 12:35 0:00 nginx: worker process
    user 114968 0.0 0.0 13164 4068 ? S 12:35 0:00 nginx: worker process
    user 114969 0.0 0.0 13164 4068 ? S 12:35 0:00 nginx: worker process
    user 114970 0.0 0.0 13164 4068 ? S 12:35 0:00 nginx: worker process

    Résultat, sur un i7-4900MQ 4 cœurs 2.8GHz

    $ ab -q -n 100000 -c 10 http://localhost:6666/ 
    This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    Benchmarking localhost (be patient).....done
    Server Software: openresty/1.21.4.1
    Server Hostname: localhost
    Server Port: 6666
    Document Path: /
    Document Length: 0 bytes
    Concurrency Level: 10
    Time taken for tests: 3.214 seconds
    Complete requests: 100000
    Failed requests: 0
    Non-2xx responses: 100000
    Total transferred: 18856993 bytes
    HTML transferred: 0 bytes
    Requests per second: 31116.39 [#/sec] (mean)
    Time per request: 0.321 [ms] (mean)
    Time per request: 0.032 [ms] (mean, across all concurrent requests)
    Transfer rate: 5730.09 [Kbytes/sec] received
    Connection Times (ms)
     min mean[+/-sd] median max
    Connect: 0 0 0.0 0 2
    Processing: 0 0 0.1 0 4
    Waiting: 0 0 0.1 0 4
    Total: 0 0 0.1 0 4
    Percentage of the requests served within a certain time (ms)
     50% 0
     66% 0
     75% 0
     80% 0
     90% 0
     95% 0
     98% 0
     99% 0
     100% 4 (longest request)

    À noter que le nombre de requètes/s dépend de l'ordinateur utilisé. Et aussi que "ab" est mono-threadé et est donc limité en performances (htstress -n 200000 -c 10 -t 8 retourne 85595 requètes/s)