DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Microservices With Apache Camel and Quarkus
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • What ChatGPT Needs Is Context

Trending

  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Microservices With Apache Camel and Quarkus
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • What ChatGPT Needs Is Context
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. Tracing Celery Performance For Web Applications

Tracing Celery Performance For Web Applications

Dan Kuebrich user avatar by
Dan Kuebrich
·
Jun. 14, 13 · Interview
Like (0)
Save
Tweet
Share
9.69K Views

Join the DZone community and get the full member experience.

Join For Free

Are you using Celery to process python back-end tasks asynchronously?  Have you wanted to get insight into their resource consumption and efficiency?  Here’s a few useful ways to get insight into Celery performance when running tasks.

A simple celery task

For a quick review, Celery lets you turn any python method into an asynchronous task.  Here’s a simple one:

Let’s trace Celery!

We’ll start with the good stuff. In the latest release of our Python instrumentation, oboeware-1.0, we have an updated API that makes it super-easy to gather performance data from any Python code, including Celery tasks. Here’s how we’d add tracing to our example task:

Celery-Oboe

The key part is the @oboe.Context.trace decorator.  Note that we’re assigning to the keys Controller and Action.  This will be used by TraceView to segment the data.  You can also optionally use the keys HTTP-Host and URL to indicate domain and URL to TraceView.  Here’s what the data we’re gathering looks like in the dashboard (I added a few sqlalchemy queries to spice up the data):

celery performance in tracelytics

The code at the top is configuration tunables: set the sample rate to a fractional value to trace only a fraction of your Celery tasks.

Event-based workers

You might be using event-based workers to save a few bytes of ram.  TraceView also supports eventlet-based workers.  However, you’ll need to install our TraceView-enabled greenlet module using pip or easy install:

1
$ pip install --extra-index-url=http://pypi.tracelytics.com greenlet-0.3.4-tly1.0

Slightly more interesting

Of course, you’re probably interested in more complex celery tasks than that.  The good news is, all of our normal instrumentation works with your celery workers.  Here’s a screenshot of one of our internal Celery workers in action:

tracing complex celery tasks

Other resources

Looking for different tools?  Good news–there’s a pretty healthy Celery ecosystem.  Here’s a few useful packages and I’m sure there’s tons I’m forgetting–leave comments for anything else you find helpful with Celery!

celery performance

  • If you want to keep track of worker status, you might be interested in celerymon, a monitor for celery tasks.  It keeps tabs of task execution and workers.
  • Trying to track down a memory leak?  Consider running dowser inside your celery worker.

Photo Credit: dottiemae

Related Articles

Tracing Python — An API

Python and gevent

Advanced SQLAlchemy & Performance Concerns

Celery (software)

Opinions expressed by DZone contributors are their own.

Trending

  • Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers
  • Microservices With Apache Camel and Quarkus
  • RBAC With API Gateway and Open Policy Agent (OPA)
  • What ChatGPT Needs Is Context

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: