Skip to Content
Python Microservices Development
book

Python Microservices Development

by Tarek Ziadé
July 2017
Beginner to intermediate
340 pages
7h 43m
English
Packt Publishing
Content preview from Python Microservices Development

Code metrics

For some microservices, it can also be useful to get performance metrics inside the code.

New Relic, for instance, will track Jinja2 and database call performances by wrapping some calls inside Flask to measure how long it takes to generate a template or perform a database call.

But adding your instrumentation inside the code needs to be done carefully if that instrumentation ships in production. Slowing down the service is easy. For instance, it's unthinkable to use Python built-in profilers because they add a significant overhead.

A simple pattern is to measure the time taken by some of your functions explicitly.

In the following example, the @timeit decorator will collect execution times for the fast_stuff() ;and some_slow_stuff() ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Microservices Development - Second Edition

Python Microservices Development - Second Edition

Simon Fraser, Tarek Ziadé
Python Web Development with Sanic

Python Web Development with Sanic

Stephen Sadowski, Adam Hopkins

Publisher Resources

ISBN: 9781785881114Supplemental Content