Reputation: 3672
I inherited a legacy app with the following structure:
gunicorn (with 64 workers) is started and pointed at a paste.deploy app, which looks like this:
from paste.deploy import loadapp
import gevent
import json
def ohmygod():
while 1:
time.sleep(30)
horrible, extremely expensive debugging function()
gevent.spawn(ohmygod)
application = loadapp('config:scripts/production.ini', relative_to='/blah')
This app's performance is business critical, but my attempts to remove this code need some profiling evidence.
I'm a little out of my league when it comes to debugging gevents inside of gunicorn though.
If I created a cProfiler inside of that function, would it pick up data from outside of the gevent, ie.: from the main ? I think this would be desirable.
A further problem is that I can't modify production code. I have access to test environments, but I can't replicate live traffic. Is it possible to safely attach to running gunicorn processes and profile them without modifying production code?
Any tips or insights much appreciated.
gunicorn v18.0, gevent v1.0.1, pyramid 1.4.5, python 2.7.6 running on Ubuntu 12 x64
Upvotes: 1
Views: 1124
Reputation: 1234
Try using app enlight middleware to figure out the bottlenecks: https://getappenlight.com/page/api/main.html
You can decorate some functions to time them separately.
Upvotes: 2