This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

mazegame: cap sockets and join rate per address

One host held ~2500 player sockets and churned thousands more; the server
spends two threads per socket and ran out of tasks for everyone.

+13
+13
2configs/mazegame.nix
··· 15 15 port = port; 16 16 }; 17 17 18 + # One address may hold a household's worth of tabs and join at a human 19 + # pace. Without this a single host opened ~2500 sockets at once and churned 20 + # thousands more, and the thread-per-socket server ran out of tasks for 21 + # everyone else. 22 + services.nginx.appendHttpConfig = '' 23 + limit_conn_zone $binary_remote_addr zone=mazegame_conns:10m; 24 + limit_req_zone $binary_remote_addr zone=mazegame_joins:10m rate=2r/s; 25 + ''; 26 + 18 27 services.nginx.virtualHosts.${domain} = { 19 28 enableACME = true; 20 29 forceSSL = true; ··· 50 59 extraConfig = '' 51 60 proxy_read_timeout 1h; 52 61 proxy_send_timeout 1h; 62 + limit_conn mazegame_conns 32; 63 + limit_req zone=mazegame_joins burst=30 nodelay; 64 + limit_conn_status 429; 65 + limit_req_status 429; 53 66 ''; 54 67 }; 55 68 locations."/api/" = {