-
Notifications
You must be signed in to change notification settings - Fork 110
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
cpu blocked for ~10s before first request on complex Flask app with gevent on 8.10.1 release #918
Comments
We have the same issue. It has killed all our applications and performance. High time it is resolved. BTW we are customer. |
Can we get some more info on this issue? A pip freeze would be very helpful if you're comfortable providing it. Or at the very least gevent and greenlet versions used. This may be related to setting I was unable to reproduce the issue on a machine running the following app. I saw no real difference in startup time. After examining the changes between
# Patch with gevent
from gevent import monkey
monkey.patch_all()
# Initialize agent
import newrelic.agent
newrelic.agent.initialize("newrelic.ini")
# Create application
from gevent.pywsgi import WSGIServer
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "Hello from Flask!"
if __name__ == '__main__':
# Start server
print("Starting gevent server...")
server = WSGIServer(("0.0.0.0", 8000), app)
server.serve_forever() |
@TimPansino another alternative would be to tell me how you want me to profile it (what tool etc) and I'll do it. Might be faster than doing a lot of tests locally. Example, I can't replicate it with the minimal code above.
The delay is ONLY before the FIRST flask request. Attached is the pip freeze. |
we run using - |
Hey all we have a fix coming for this to be released on Monday Nov 13th. |
This fix was released in v9.1.2. |
@hmstepanek this is not fixed in v9.1.2 (I just tested locally). Can you re-open the issue? Same as in the issue body (8s+ to load the first page with 100% CPU) |
@ddorian it sounds like there may be multiple issues here. We fixed the importlib metadata issue but sounds like that wasn't the root of the problem in your case. Could you try out this branch and let us know if it reduces the cpu spike: https://github.com/newrelic/newrelic-python-agent/tree/performance-cpu-increase-possible-fix. If it doesn't reduce the CPU usage, could you send us a cprofile dump of the first transaction hitting your application? Something like the following should be sufficient for profiling: |
@hmstepanek just tested it, and it works! Thank you! |
We just released a new configuration option that you can add to you newrelic.ini config file |
Thank you |
Hi,
I have a pretty complex flask app locally that hangs for about ~10s ONLY before the first request when using 8.10.1 release (doesn't happen on 8.10.0). Still happens on 9.0.0 though. The CPU usage is 100% for those seconds. All the other requests work normally after.
How do you want me to profile it? Using ubuntu 22.04 & Python 3.11 and many libraries.
The text was updated successfully, but these errors were encountered: