惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家
V
V2EX
Jina AI
Jina AI
V
Visual Studio Blog
有赞技术团队
有赞技术团队
博客园 - 司徒正美
博客园 - 叶小钗
The Cloudflare Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
Google Online Security Blog
Google Online Security Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic
N
News and Events Feed by Topic
The Last Watchdog
The Last Watchdog
W
WeLiveSecurity
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
SecWiki News
SecWiki News
博客园_首页
罗磊的独立博客
量子位
Latest news
Latest news
I
Intezer
V
Vulnerabilities – Threatpost
A
Arctic Wolf
Last Week in AI
Last Week in AI
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
SegmentFault 最新的问题
S
Security Affairs
阮一峰的网络日志
阮一峰的网络日志
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Palo Alto Networks Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
N
News | PayPal Newsroom

博客园 - 取经路上

IIS 下发布SignalR 访问接口进不去处理 Linux下部署.Net 应用程序和Web应用程序 CentOS 7 配置启动 手动编译的 nginx CentOS 7 nginx 安装 sticky模块 C# 调用迅雷aplayer播放器的遇到的问题总结 C# 采用HttpWebRequest 、WebClient和HttpClient下载https的文件异常问题 C# 判别系统版本以及Win10的识别办法 MVC ActionResult 视图模型 MVC 前后台传值 MVC基础关键点 sqlserver 数据库、日志文件收缩 笔记 vue-cli启动报错问题: IE6无法获取class属性 windows server 2008 r2 datacenter 共享服务找不到网络路径解决办法 在Visual Studio 中的监视窗口中监视Com对象变量 删除GitHub上项目中的某个文件 转 WPF MVVM 循序渐进 (从基础到高级) 服务器未能识别 HTTP 头 SOAPAction 的值: http://tempuri.org/QueryUserName。
关于SignalR并发量测试
取经路上 · 2024-06-27 · via 博客园 - 取经路上

由于业务需要,需要做一个强制下线的功能(类似QQ、钉钉这种在相同平台上登录多个账号,下线之前已登录的账号)。

经过一些列的调研,发现SignalR这个框架实现起来比较简单

由于我们的客户是零散的终端用户,并发量是首先需要考虑的,写个测试案例进行连接实例测试。

创建了一台虚拟机Centos7版本,开始连接,每次连接不到1024个,就无法建立连接了

这里主要有2个原因,

第1个是linux的文件访问数量被限制,可以通过命令ulimit -n 查看1024

第2个是nginx的默认最大连接数也是1024.

需要进行如下调整,为了测试并发量,下面的并发数量统一设置为102400左右进行验证

**增加系统资源限制

编辑 /etc/sysctl.conf,添加或修改以下内容:
fs.file-max =102400
net.core.somaxconn = 65535
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15

编辑 /etc/security/limits.conf 文件,添加以下内容:
* soft nofile 102400
* hard nofile 102400

/etc/systemd/system.conf 文件中添加或修改以下行:
DefaultLimitNOFILE=102400
DefaultLimitNPROC=102400  #这行可以先不加

/etc/systemd/user.conf 文件中添加或修改以下行
DefaultLimitNOFILE=102400
DefaultLimitNPROC=102400  #这行可以先不加



调整 Nginx 配置
worker_processes auto;
worker_rlimit_nofile 102400;
events {
    worker_connections 102400;
    multi_accept on;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    keepalive_timeout  65;
    types_hash_max_size 2048;
    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
  #server 这部分可以单独配置在  /etc/nginx/conf.d/*.conf;
    server {
        listen 80;
        server_name 192.168.208.131;

        location / {
            proxy_pass http://localhost:5000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}

经过上面的一些列设置后,本机可以连接过万,部署到云端服务器,同时拥有7台终端进行连接,测试并发量到1.7万连接没有问题,由于终端数量有限,无法测试更多的连接。理论上应该是支持更多的连接。