Skip to content

计数器算法

nginx
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    # 限制同一用户并发数
    limit_conn_zone $binary_remote_addr zone=one:10m;

    server {
        listen       80;
        server_name  localhost;

        location / {
            # 限制同一用户并发数为 1
            limit_conn one 1;
            root html;
            index index.html;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}