マイン マイン
システム開発


About web application that handles thousands users

About web application that handles thousands users

Imagine we are going to write an web app which concurrent users scales to thousands, how do we do?

1. Buy powerful server: more RAM, use SSD with RAID… Yeah it’s first thought to consider. But we can improve existing server capable by software tuning.

2. This is known as “C10K problem”. First we need to lift some Linux’s server params about networking and file open. It’s on the kernel, need tweaking and restart.


# Reference https://gist.github.com/jedi4ever/903751
# /etc/sysctl.conf

fs.file-max = 999999
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216

2. Why Nginx existed while there is Apache?

Because Nginx is event-driven server. Each request is handled as an event. On opposite, Apache spawned a new process / thread on each request, and occupies lot more memory and resources. That’s why Nginx is suitable for serving static contents much better than Apache. Using Nginx-like server may boost performance.

4. An important point is on traditional web application: app run, process requested and shutdown. App also has to start up, wait for synchronous I/O tasks, …

To handle more users, an alternative model is: App act as a server with event-driven processing model. NodeJS is successful story based on this approach.

For PHP, we can use ReactPHP.
For Python, we can use Tornado.
(I don’t know any solution with Ruby, RoR).

5. This picture is not complete, but I hope it helps to outline a plan to built faster and better web application solution.

この記事を書いた人
マイン

ベトナム生まれの開発者、私はPHPとかCSS/JS/HTML/Linux server経験があります。ひまの時に日本語は勉強します。

札幌市中央区北3条西26丁目3-8 N2ビル3F 〒064-0823 TEL:011-640-5437 FAX:011-640-5434
東京都港区六本木4丁目2-35 アーバンスタイル六本木三河台2F 〒106-0032 TEL:03-5772-1414 FAX:03-5772-1404
NADIA BANGKOK / 240 soi 52 Romklao Road Ladkrabang Bangkok 10520 Thailand
NADIA HANOI / 5F, SIMCO Bld., 28 Pham Hung, Ha Noi, Viet Nam
PAGETOP
ナディアFacebookページ株式会社ナディア|Nations Media Design Nadia
PAGE TOP ↑