Python in production engineering

Visit the post for more.

Romain Komorn
5 min readintermediate
--
View Original

Overview

The article discusses the extensive use of Python in production engineering at Facebook, highlighting its significance in the infrastructure codebase and various operational tools. It provides insights into how Python facilitates faster development and efficient management of services within Facebook's infrastructure.

What You'll Learn

1

How to utilize Python for infrastructure management at scale

2

Why using Python libraries can enhance operational efficiency

3

When to transition from Python 2 to Python 3 in production environments

Key Questions Answered

What percentage of Facebook's infrastructure codebase is written in Python?
21 percent of Facebook Infrastructure’s codebase is written in Python, showcasing its critical role in the company's software ecosystem.
How many commits to Python code does Facebook see on average each month?
Since 2016, Facebook has averaged 5,000 commits per month to Python code, with over 1,000 committers contributing to the codebase.
What tools does Facebook use for service configuration management?
Facebook uses Chef for host-level configuration management and a project called Configerator for service-level configuration management, enabling dynamic generation of configuration objects in JSON format.
What are some key services powered by Python at Facebook?
Python powers various services at Facebook, including network switch setup, auto-remediation of server faults, and job scheduling through platforms like Job Engine and fbpkg.

Key Statistics & Figures

Percentage of codebase
21 percent
This represents the proportion of Facebook's infrastructure code that is written in Python.
Average commits per month
5,000 commits
This average has been maintained since 2016, indicating a high level of ongoing development.
Number of committers
1,000+ committers
This reflects the collaborative effort of many engineers contributing to the Python codebase.
Percentage of Python 3 usage
5 percent
As of May 2016, this is the proportion of Python services in production that are running Python 3.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Programming Language
Python
Used extensively for building and maintaining libraries and services within Facebook's infrastructure.
Framework
Thrift
Used for maintaining Python client libraries that provide interfaces for services.
Configuration Management
Chef
Used for host-level configuration management.
Configuration Management
Configerator
A Facebook-authored project for service-level configuration management.
Library
Asyncio
Utilized in Python 3 for asynchronous programming to improve performance.

Key Actionable Insights

1
Leverage existing Python libraries to reduce development time and improve reliability.
By using well-maintained libraries, production engineers can focus on integrating services rather than writing boilerplate code, thus speeding up deployment and enhancing system reliability.
2
Consider transitioning to Python 3 to take advantage of performance improvements.
As Facebook continues to move towards Python 3, utilizing its features like AsyncIO can lead to significant performance gains, especially for high-scale applications.
3
Implement automated tools for infrastructure management to enhance operational efficiency.
Using tools like FBAR for auto-remediation and Dapper for scheduling can streamline maintenance tasks and reduce manual intervention, leading to a more resilient infrastructure.

Common Pitfalls

1
Neglecting to transition from Python 2 to Python 3 can lead to performance issues.
As Python 2 is phased out, continuing to use it may hinder performance and limit access to new features available in Python 3.