PageRenderTime 27ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/frameworks/Python/README.md

https://gitlab.com/lcp0578/FrameworkBenchmarks
Markdown | 126 lines | 74 code | 52 blank | 0 comment | 0 complexity | 20f77049aec611b7f202ba169e216e83 MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, Apache-2.0
  1. # Python frameworks
  2. The information below contains information specific to Python.
  3. For further guidance, review the
  4. [documentation](http://frameworkbenchmarks.readthedocs.org/en/latest/).
  5. ## Infrastructure Software Versions
  6. * [Python2 2.7.10](https://www.python.org/)
  7. * [Python3 3.4.3](https://www.python.org/)
  8. * [PyPy 2.6.0](http://pypy.org/)
  9. * [nginx](http://nginx.org/)
  10. ## Get Help
  11. ### Python Experts
  12. * INADA Naoki (@methane) -- Expert of Python and Python's MySQL driver.
  13. * Ludovic Gasc (@GMLudo) -- Expert of AsyncIO.
  14. ### [Python Community](https://www.python.org/community/)
  15. * `#python` IRC Channel ([irc.freenode.net](http://freenode.net/))
  16. * `#python-dev` IRC Channel ([irc.freenode.net](http://freenode.net/))
  17. ## Python interpreters
  18. ### (C)Python 3
  19. Newest Python.
  20. It will be most major interpreter for Web Development in this or next year.
  21. This is a bit slower than CPython 2, but more simple and productive than it.
  22. ### (C)Python 2
  23. Legacy Python.
  24. It is most major interpreter for now.
  25. ### PyPy
  26. PyPy is the fastest Python implementation with JIT.
  27. There is PyPy's Python 3 implementation (PyPy3), but it is not so tuned like PyPy2.
  28. So we don't use it for now.
  29. ## WSGI Servers
  30. ### Nginx + uWSGI
  31. This is one of fast and realistic way to serve Python web application.
  32. Use unix domain socket between nginx and uWSGI to avoid additional TCP/IP overhead.
  33. ### Gunicorn + Meinheld
  34. [Meinheld](https://github.com/mopemope/meinheld) is very fast WSGI server.
  35. Since Meinheld is safe against slowloris and support Keep-Alive, you can use it
  36. without buffered HTTP reverse proxy (like nginx).
  37. We use meinheld to measure bare (without DB access) performance of framework without
  38. overhead of reverse proxying. (plaintext, json test)
  39. Meinheld does not provide worker process management.
  40. [Gunicorn](http://gunicorn.org/) provide it for Meinheld.
  41. ### Gunicorn + Tornado
  42. uWSGI + PyPy is difficult to setup.
  43. Meinheld doesn't so fast with PyPy because it uses Python/C API heavily.
  44. So we use Tornado as HTTP/WSGI server.
  45. It supports keep-alive. So it have nice performance about json or plaintext benchmark.
  46. ## Before writing new tests.
  47. **Don't increase matrix without significant purpose.**
  48. We can't maintain matrix of frameworks (5~) * servers (3~) * DBs (3) * Interpreters (3).
  49. If you want to know about performance difference between MySQL and PostgreSQL,
  50. there are no need to all frameworks implement both of them.
  51. Additionally, Python is not a good language to measure performance of DBs because
  52. web application written in Python is slower than DBs.
  53. If you want to benchmark http server, you should not port all tests or frameworks.
  54. Simple json or plaintext test is enough.
  55. If your framework uses SQLAlchemy, Flask may be enough to know performance of SQLAlchemy.
  56. ## Advice when writing new tests
  57. ### Interpreter
  58. Consider Python 3 first. -- Python 3 will be mainstream for web development soon.
  59. ### Server
  60. Try Gunicorn + Meinheld first. All WSGI apps in this benchmark uses it. You can compare
  61. your framework performance with others.
  62. ### Files you should provide
  63. You can see Flask's files to know how to write new test.
  64. `requirements.txt` is standard way to define depending libraries.
  65. `install.sh` is executed before running test. You should create virtualenv on `$TROOT/py2`
  66. (or py3 for Python 3 and pypy for PyPy). Then `$TROOT/py2/bin/pip install -r requirements.txt`.
  67. virtualenv is installed on Python 2 and PyPy. Use `$IROOT/py3/bin/python3 -m venv $TROOT/py3`
  68. for Python 3.
  69. You can set environment variables within `install.sh` or within `setup.sh`.
  70. `bechmark_config` is json file to define test.
  71. See [here](http://frameworkbenchmarks.readthedocs.org/en/latest/Codebase/Framework-Files/#benchmark-config-file).
  72. `setup_py2.sh` is used to run test on Python 2. `gunicorn_conf.py` is configuration for gunicorn.
  73. `setup_py2.sh` and `gunicorn_conf.py` are written as generic as possible.
  74. You may be able to use it with changing wsgi callable. (`$PY2_GUNICORN wsgimodule:callable -c gunicorn_conf.py`)