Too high count of threads on "open source" passenger core process
216 views
Skip to first unread message
Pascal Chambon
unread,
Jun 12, 2016, 6:13:31 AM6/12/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Phusion Passenger Discussions
Hello,
I've deployed an open soucre version of passenger, meaning that passenger_thread_count is not available, the single process "passenger core" is supposed to be single-threaded.
However htop shows 70+ threads in the passenger core process, only 2-3 of which are dedicated to the RubyApp (redmine).
I don't need so many passenger threads, since anyway only 1 will handle the app request (theoretically), and because my host limit the number of threads on my accounts, these 70+ threads are blocking my other applications (python etc.).
Is teher any way to limit the number of connection-handling threads in passenger core, in the open source version ?
My performance conf in NGINX: passenger_max_pool_size 1; passenger_min_instances 1; passenger_spawn_method conservative;
Thanks a lot, regards, P. C.
Pascal Chambon
unread,
Jun 12, 2016, 6:37:56 AM6/12/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Phusion Passenger Discussions
Follow-up:
by browsing the passenger open-source code, I've found these two settings : DEFAULT_APP_THREAD_COUNT = 1 ... options.setDefaultInt("app_thread_count", DEFAULT_APP_THREAD_COUNT); // THIS seems to be the real "single-threaded server" setting
// THIS seems to be the problem with excessive request-handling threads : printf(" --threads NUMBER Number of threads to use for request handling.\n"); printf(" Default: number of CPU cores (%d)\n", boost::thread::hardware_concurrency()); ... if (options.getInt("core_threads") < 1) { fprintf(stderr, "ERROR: you may only specify for --threads a number greater than or equal to 1.\n"); ok = false;
The question is so : is there any way to set this "core threads" setting, when using passenger with nginx and not as standalone (in which case this " --threads" setting should do the trick) ?
Hongli Lai
unread,
Jun 13, 2016, 5:22:55 AM6/13/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phusion-passenger
Use you can 'passenger_ctl core_threads 1'. It defaults to the number
of CPU cores on your system.
But I don't think that's the full story. The Passenger core controller
processes requests in a hybrid multithreaded/evented manner, but there
are additional background threads for handling stuff like I/O,
spawning, stdout capturing, etc. Those cannot be configured.
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Phusion Passenger Discussions, hon...@phusion.nl
Thanks for your answer,
by hacking the sources of standalone startup scipt (in ruby), I've forced to launche only 2 core threads, and in total the passanger-core now uses a dozen threads, which seems fine to me.
I'dl like to use the nginx integration and not this hacked standalone, but I can't find the passenger_ctl command, is it specific to Passenger Enterprise ? I only have passenger-status and passenger-config which resemble this, but they don't allow these command line args... And as far as I've seen, nginx-integrated passenger doesn't expose the core-threads option.
thanks, regards, P. Chambon
Daniel Knoppel
unread,
Jun 13, 2016, 7:46:47 AM6/13/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Phusion Passenger Discussions, hon...@phusion.nl
passenger_ctl is not a command but a configuration option that you can use in your nginx config.
- Daniel
Pascal Chambon
unread,
Jun 14, 2016, 4:35:17 AM6/14/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to phusion-...@googlegroups.com, hon...@phusion.nl
Thanks a lot for the information,
since I've already moved to a standalone server, here is an example Passengerfile.json which uses an nginx backend and sets core_threads to 2, in case it might help someone. It passes "passenger_ctl core_threads 2' to the internal nginx conf by using "ctls" syntax, without having to resort to a custom nginx template. { "address": "0.0.0.0", "port": "22159", "instance_registry_dir": "/home/user/redmine323/tmp", "environment": "production", "ruby": "/home/user/redmine323/bin/ruby" "app_type": "rack", "startup_file": "config.ru", "spawn_method": "direct",
"envvars": {},
"engine": "nginx", "ctls": ["core_threads=2"], // HERE is the important part "max_pool_size": 1, "min_instances": 1 "daemonize": true, "log_file": "/home/user/logs/user/error_redmine323.log",