ab -n100000 -c1000 -r http://localhost:9004/ # append /etc/security/limits.conf # for a specific user # sudo sh -c 'printf "'$USER' soft nofile 1000000" >> /etc/security/limits.conf' # for all users sudo sh -c 'printf " * soft nofile 1000000 * hard nofile 1000000 * soft nproc 1000000 * hard nproc 1000000" >> /etc/security/limits.conf' # sudo vim /etc/security/limits.conf http://linux-quirks.blogspot.de/2011/02/too-many-open-files.html # append /etc/sysctl.conf sudo sh -c 'echo "fs.file-max = 1000000" >> /etc/sysctl.conf' # sudo vim /etc/sysctl.conf sudo sysctl -p otherwise restart server! a@t400:~$ ulimit -n 999999 bash: ulimit: open files: cannot modify limit: Operation not permitted root@ubuntu:~# sudo su - ulimit -n 999999 ------- ulimit -n socket: Too many open files (24) Error ------------------------------------------------- http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ http://askubuntu.com/questions/100183/nginx-testing-with-ab-not-working-with-high-number-of-concurrent-connections ------------------------------------------------- wget http://gevent.googlecode.com/files/gevent-1.0b2.tar.gz tar -xvf gevent-1.0b2.tar.gz cd gevent-1.0b2 sudo python setup.py install
# https://github.com/mopemope/meinheld sudo easy_install -ZU meinheld
from meinheld import server def hello_world(environ, start_response): status = '200 OK' res = "Hello world!" response_headers = [('Content-type','text/plain'),('Content-Length',str(len(res)))] start_response(status, response_headers) return [res] server.listen(("0.0.0.0", 8000)) server.run(hello_world)
sudo apt-get install apache2-utils -y
a@a:~$ cat ge.py from gevent import wsgi class WebServer(object): def application(self, environ, start_response): start_response("200 OK", []) return ["Hello world!"] host,port='',8888 if __name__ == "__main__": app = WebServer() print ("started server at {}:{}".format(host,port)) wsgi.WSGIServer((host, port), application=app.application, log=None).serve_forever()
import bjoern def wsgi_app(env, start_response): start_response("200 OK", []) return ["Hello world!"] host,port='0.0.0.0',8889 if __name__ == "__main__": print ("started server at {}:{}".format(host,port)) bjoern.listen(wsgi_app, host, port) bjoern.run()
>> vi gx.py
import eventlet from eventlet import wsgi def hello_world(env, start_response): start_response('200 OK', [('Content-Type', 'text/plain')]) return ['Hello, World!\r\n'] wsgi.server(eventlet.listen(('', 8090)), hello_world, file('/dev/null', 'w'))
a@a:~$ sudo easy_install gevent
sudo apt-get install libev-dev -y
sudo easy_install gevent
sudo pip install bjoern
sudo pip install eventlet
————————— Too Many Open Files —————————
a@a:~$ python ge.py
a@a:~$ ab -n10000 -c4000 http://localhost:8888/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> 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) socket: Too many open files (24) a@a:~$ ab -n10000 -c2000 http://localhost:8888/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> 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) socket: Too many open files (24) a@a:~$ ulimit -n 1024 a@a:~$ ulimit -n 100000 bash: ulimit: open files: cannot modify limit: Operation not permitted a@a:~$ sudo ulimit -n 100000 sudo: ulimit: command not found ---------- c10k # Автор andribas, дата создания 9 марта, 2009 - 17:45.
> ulimit
unlimited
> ab -n 100000 -c 2000 -k http://localhost:9000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
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)
socket: Too many open files (24)
>> httperf –hog –client=0/1 –server=localhost –port=8080 –uri=/index.html –rate=10000 –send-buffer=4096 –recv-buffer=16384 –num-conns=1000000 –num-calls=1
> ulimit -aH core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 63200 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 4096 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) unlimited cpu time (seconds, -t) unlimited max user processes (-u) 63200 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited > sudo su - ulimit -Hn 1000000 ulimit -Hu 1000000 ulimit -Hi 1000000 ulimit -Hq 1000000 > sudo vi /etc/security/limits.conf userhttp soft nofile 1000000 userhttp soft nproc 1000000