擅长:python、mysql、java
<p>正如前面的回答所述:</p>
<ol>
<li>增加内核中的连接</li>
<li>在uWSGI中增加连接<strong>也<strong></li>
</ol>
<p><strong>示例</strong>。如果您使用的是<strong>docker</strong>和<strong>docker compose</strong>。</p>
<ol>
<li>如何在内核中增加连接</li>
</ol>
<p>在<code>docker-compose.yml</code>中,在描述如何运行uWSGI的块中:</p>
<pre><code>uwsgi_runner:
<<: *app-base
command: /usr/local/bin/uwsgi --ini /app/uwsgi.ini
# ... other settings ...
sysctls:
net.core.somaxconn: 1024 # set max connections to 1024 in kernel
</code></pre>
<ol start=“2”>
<li>如何在uWSGI中增加连接</li>
</ol>
<p>在<code>uwsgi.ini</code>中:</p>
<pre><code>[uwsgi]
# ... other settings ...
listen = 1024 # set max connections to 1024 in uWSGI
</code></pre>
<p>此外,如果不使用<code>uwsgi.ini</code>设置文件,则可以在<strong>docker compose命令</strong>(<code>-l</code>或<code>--listen</code>标志)中直接更改此参数:</p>
<pre><code>uwsgi_runner:
<<: *app-base
command: /usr/local/bin/uwsgi -l 1024 #other-parameters-here
</code></pre>