Use minions to learn epoll lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Tz · 2019-08-04 02:49 Im looking for epoll and start searching this forum and found this topic https://forum.lazarus.freepascal.org/index.php/topic,9352.0 but it was so long ago, and feel a progress way too little, thanks for hint from zamronypj I would make epoll a new start, even just a bit, and here epoll with minions. Hope someone can make start on iocp too. What I learn   1. Thundering herd problem, to avoid that, I simply use single thread (main thread)      so no listener sharing. For scale just increase SOMAXCONN.      Anyone would like to try Acceptor Thread as number of core cpu?   2. A listener use level trigger, and for acceptor use edge trigger,      and by these all message should be full in one transmission,      best for short message, but dont know for large bytes such upload file.      just I dont know how to do it.   3. A processing of ready list, after epoll wait, we have to process much much faster.      My first attempt use single thread it just block.      For accept should be fast just set option and register to epoll (epoll.add)      And for EPOOLIN I use to spawn a minion thread,      I think this is good for concurency, and can process asynchronously.      and dont forget to  FreeOnTerminate := true;      Also we can try to create a thread pool, to reduce of thread cost creation?      any clue ?   4. Some socket option still need tuning, theres note in zsockopt.pas      and refer to these topic https://forum.lazarus.freepascal.org/index.php/topic,44788.0      for benchmarking.      And this my current benchmark. $ ab -n 9000 -c 9000 http://localhost:8000/ This is ApacheBench, Version 2.3 <$Revision: 1807734 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient) Completed 900 requests Completed 1800 requests Completed 2700 requests Completed 3600 requests Completed 4500 requests Completed 5400 requests Completed 6300 requests Completed 7200 requests Completed 8100 requests Completed 9000 requests Finished 9000 requests Server Software: Server Hostname:        localhost Server Port:            8000 Document Path:          / Document Length:        37 bytes Concurrency Level:      9000 Time taken for tests:   0.885 seconds Complete requests:      9000 Failed requests:        0 Total transferred:      1386000 bytes HTML transferred:       333000 bytes Requests per second:    10170.11 [#/sec] (mean) Time per request:       884.946 [ms] (mean) Time per request:       0.098 [ms] (mean, across all concurrent requests) Transfer rate:          1529.49 [Kbytes/sec] received Connection Times (ms)               min  mean[+/-sd] median   max Connect:      142  216  42.0    218     288 Processing:   155  257 100.2    229     458 Waiting:      122  251 106.9    229     458 Total:        405  473  60.3    447     601 Percentage of the requests served within a certain time (ms)   50%    447   66%    494   75%    522   80%    538   90%    571   95%    586   98%    595   99%    598  100%    601 (longest request) the code is not good enough, but I hope we all can make another start. Lets make Pascal great again attach source code.