Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithreading support for python amd how does ngonx-unitnis different from apache web server #33

Closed
eulhaque opened this issue Sep 13, 2017 · 9 comments
Labels

Comments

@eulhaque
Copy link

ningx unit delegates request to individual python worker processes, right? Is there a way to allow multiple threads in each python worker processs so for io bound application we can use threads and increase the number of request to handle?

Also just wondering how is it different than apache web server which has almost the same offering and you can even run multiple applications using the same server via different virtualhost configs?

@VBart
Copy link
Contributor

VBart commented Sep 18, 2017

Is there a way to allow multiple threads in each python worker processs so for io bound application we can use threads and increase the number of request to handle?

Currently there's only one Python application thread per application process. Support for multiple threads is planned.

Also just wondering how is it different than apache web server which has almost the same offering and you can even run multiple applications using the same server via different virtualhost configs?

How is nginx different from apache?

Unit uses completely different, modern architecture. It contains main, controller, router, and application processes. Each process is isolated for specific purpose, which makes Unit extremely secure and robust.

  • The router process is like improved version of nginx, it contains a number of threads and each thread is like an nginx worker process. They are asynchronous and can handle millions of connections simultaneously with minimal resources.
  • The controller process provides RESTful JSON API interface, which is very easy to use. All configuration changes are applied dynamically and gracefully without reloading and connections loss.
  • The application processes can dynamically load any versions of any interpreters independently and simultaneously. They communicate with the router process using very fast IPC, that is based on shared memory segments and adds minimum overhead to request processing.

Thus, it is modern, fast, secure, lightweight and dynamically reconfigurable server. When Unit will be production ready and feature rich, it will significantly simplify web stack and improve scalability.

@VBart VBart added z-enhancement ⬆️ Product Enhancement z-question labels Sep 18, 2017
@eulhaque
Copy link
Author

Thanks for the explanation VBart. Looking forward for the threading support in python. Do you know the timeline of Python Application Threads? Also, I know it is related to same, are there any plans to support asynchronous calls (i.e. async io or event based concurrency in python)?

@VBart
Copy link
Contributor

VBart commented Oct 10, 2017

@eulhaque It's not in a short term plan. Our current goal is to stabilize current functionality and provide all the essentials to run classic WSGI applications. While threads support is a good optimization, it's less important than some other features that Unit is currently missing to be suitable for production use.

@urba1n
Copy link

urba1n commented Apr 18, 2018

As Unit has reached v1.0, have you a vision when threads for python can be supported ? I tried, unsuccessfully, to use New Relic with Unit v1.0 and according to New Relic support, the problem is related to the lack of threading support in Unit.

@VBart
Copy link
Contributor

VBart commented Apr 18, 2018

@urba1n this ticket is about running WSGI applications in multiple threads in order to reduce memory usage. It has nothing to do with threading support inside Python. It should work well already. What's the problem with New Relic?

@urba1n
Copy link

urba1n commented Apr 19, 2018

Sorry, New Relic support points me to this particular issue, saying the issue is related the way NGINX Unit disallows multiple threads. Using new relic I get the following errors which prevents the application from running.
Apr 19 08:08:31 unit_as - Fatal Python error: GC object already tracked Apr 19 08:08:32 unit_as - 2018/04/19 08:08:31 [alert] 1#1 process 18 exited on signal 6 (core dumped) Apr 19 08:08:32 unit_as - 2018/04/19 08:08:31 [info] 17#39 *11 shutdown(50, 2) failed (107: Transport endpoint is not connected) Apr 19 08:08:32 unit_as - 2018/04/19 08:08:31 [info] 50#50 "unit-1|18-04-2018|17:33:54" application started Apr 19 08:08:32 unit_as - Fatal Python error: GC object already tracked Apr 19 08:08:32 unit_as - 2018/04/19 08:08:32 [alert] 1#1 process 23 exited on signal 6 (core dumped) Apr 19 08:08:32 unit_as - 2018/04/19 08:08:32 [info] 17#39 *26 shutdown(51, 2) failed (107: Transport endpoint is not connected) Apr 19 08:08:32 unit_as - 2018/04/19 08:08:32 [info] 55#55 "unit-1|18-04-2018|17:33:54" application started Apr 19 08:08:33 unit_as - 2018/04/19 08:08:33 [notice] 50#50 signal signo:17 (SIGCHLD) recevied, ignored
Should I open a new issue related to that ?

@VBart
Copy link
Contributor

VBart commented Apr 19, 2018

@urba1n You can open it in order to track updates and share information with community. We have already seen this error on another application. A fix for it is on review right now. It's not related to threads, but to a bug in our WSGI implementation.

@urba1n
Copy link

urba1n commented Apr 19, 2018

Thank you very much. Issue #107 has been opened.

@VBart
Copy link
Contributor

VBart commented Sep 24, 2021

Multithreaded request processing in Python apps can be configured since Unit 1.21.0.
See the docs: https://unit.nginx.org/configuration/#python

@VBart VBart closed this as completed Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🚀 Released
Development

No branches or pull requests

3 participants