Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Reducing CPU overhead


#1

New Relic 2.76.0.55, Python 3.5.2, Gunicorn 19.6.0, Falcon 1.1.0

I’ve been trying for the last few months to reduce the CPU usage of my API gateway (always a challenge in Python), so I was curious to see how much CPU usage the NR agent causes.

I have two boxes, c4.large AWS instances, doing ~8k RPM. On the one running the agent, I’m using 29% of the CPU. On the one not running the agent, I’m using 15%.

This seems like a significant amount of overhead just to run APM stat collection! My newrelic.ini file is fairly standard, no strange includes or excludes. Is there anything I should do to reduce the CPU usage of the agent?


#2

@jbennett1 We wanted to move this into a support ticket to get some more specifics of what you are experiencing. Thanks and look for an email from Support!


#3

@jbennett1

Like all application monitoring solutions, there is some fixed work that the Python agent will perform for each transaction. Monitoring your is code never totally “free”. That said, we always try to keep this work to a minimum and in most situations, it is hardly noticeable and well worth the cost for the power that New Relic brings to understanding the performance of your services and applications.

For example, on a typical Django view request that takes a few hundred milliseconds, the work the agent does is a small proportion of the total time of the whole request and response cycle. However, if you are monitoring a very lightweight API where calls to its endpoints run in just a few milliseconds, you may see the agent’s work as a larger proportion of the total work.

While some of the work performed by the agent is fixed, there are a few tweaks that can be made to help reduce the CPU cycles used. In your particular case, we suggested that, if possible, you could disable the Redis instrumentation to help save some CPU processing power. The amount that this will help will depend on how Redis is used in the application.

You may also want to consider whether it is important to monitor a particular endpoint at all. If you are already monitoring the applications which call an endpoint, the data the callers report on the response time of their requests to this service may be sufficient for your needs. If certain endpoints on the API service are particularly lightweight, you could use the New Relic API to ignore transactions for those specific endpoints.


#4

Appreciate all of your work on this issue.

One thing that occurred to me, is whether it would be possible to NR to “turn down the resolution” and sample fewer incoming requests. If I’m running 15k RPM, I don’t need to report back 15k times a minute - sampling a few thousand requests would be sufficient.

Is that an approach you guys have considered?


#5

That is an excellent suggestion and some version of that could be a viable solution to this type of use-case.

The “how” of doing this is a little more complicated than it might seem, but this is a great feature request that the Engineering and Product management teams will discuss and consider as a future improvement to the agent.

We will be sure to respond in this thread as updates are available.

Thanks again for the great conversation on this issue.


#6

Hello was any work done for feature mentioned above? Thanks.


#7

No news to share on this suggestion yet, @SZarouski - do you care to share a bit about your needs and your use case? I will happily pass them along to the teams that will want to know! :blush: