PyXtrim cuts serverless python app startup time and memory use
Reducing Cold-Start Latency in Serverless Applications via Dynamic Slicing
Distributed, Parallel, and Cluster ComputingProgramming LanguagesSoftware Engineering
Summary
Serverless applications can be slow to start, especially when using Python, which is complex and dynamic. The authors created PyXtrim, a tool that finds and removes parts of the application and its dependencies that aren’t needed for its visible behavior. It does this by tracking what code parts interact with the system, even across Python and native code. This results in faster startup and lower memory use for these applications.
What this means in practice
- •For cloud platform engineers: Reduce cold-start delay and memory footprint for Python apps running on serverless cloud platforms like AWS Lambda.
- •For python extension developers: Optimize mixed Python and native code software to minimize unnecessary dependencies and speed up startup in serverless environments.
Authors
Georgios Alexopoulos, Konstantinos Karakatsanis, Nikolaos Alexopoulos, Dimitris Mitropoulos, Thodoris Sotiropoulos
Abstract
We present PyXtrim, a system that reduces the cold-start latency of serverless applications through debloating. We focus on Python, a dominant language for serverless applications whose dynamic features and extensive use of native extensions make traditional static debloating particularly challenging. PyXtrim frames debloating as a dynamic slicing problem, using the application's externally visible behavior as the slicing criterion. Everything outside the resulting slice is removed, both from the application and its dependencies. Our key technical contribution is that the slice is computed by a cross-language dynamic dependence engine that tracks data and control dependences across Python and native code and identifies operations that interact with the operating system, which form the slicing criterion. As a result, PyXtrim can effectively handle real-world applications that rely on dynamic features such as reflection, interoperate with native code and interact with system resources. Across 31 applications on AWS Lambda, PyXtrim reduces cold-start latency by 21.7% and peak memory usage by 17.1% at the median. This is more than double the reduction achieved by the state of the art, while debloating each application in minutes.