如何通过优化LMDB内存管理提升我们的API服务性能

Angel Vargas | Software Engineer, API Platform; Swati Kumar | Software Engineer, API Platform; Chris Bunting | Engineering Manager, API Platform

Angel Vargas | 软件工程师,API 平台;Swati Kumar | 软件工程师,API 平台;Chris Bunting | 工程经理,API 平台

The inside of the Pinterest lobby in Mexico City, showing a patterned ceiling, a receptionist deck with a plant on it, a light above it, and a gallery of images of pins you’d find on Pinterest, behind it. To the left, a glowing Pinterest P sign hovers in front of a glass wall.

墨西哥城 Pinterest 大厅内部,展示了一个有图案的天花板,一个带有植物的接待台,上方有一个灯,后面是一组 Pinterest 上可以找到的图钉图片画廊。左边,一个发光的 Pinterest P 标志悬浮在玻璃墙前。

NGAPI, the API platform for serving all first party client API requests, requires optimized system performance to ensure a high success rate of requests and allow for maximum efficiency to provide Pinners worldwide with engaging content. Recently, our team made a significant improvement in handling memory pressure to our API service by implementing a Lightning Memory-Mapped Database (LMDB) to streamline memory management and enhance the overall efficiency of our fleet of hosts. To handle parallelism, NGAPI relies on a multi-process architecture with gevent for per-process concurrency. However, at Pinterest scale, this can cause an increase in memory pressure, leading to efficiency bottlenecks. Moving to LMDB reduced our memory usage by 4.5%, an increase of 4.5 GB per host, which allowed us to increase the number of processes running on each host from 64 to 66, resulting in a greater number of requests each host could handle and better CPU utilization, thus reducing our overall fleet size. [1] The result? More happy Pinners, per host!

NGAPI 是用于处理所有第一方客户端 API 请求的平台,需要优化系统性能以确保高请求成功率并最大限度地提高效率,为全球 Pinners 提供引人入胜的内容。最近,我们的团队通过实施 Lightning Memory-Mapped Database (LMDB) 来简化内存管理并提高我们主机群的整体效率,从而在处理 API 服务的内存压力方面取得了重大改进。为了处理并行性,NGAPI 依赖于多进程架构,并使用 gevent 实现每个进程的并发。然而,在 Pinterest 规模下,这可能会导致内存压力增加,从而导致效率瓶颈。迁移到 LMDB 使我们的内存使用量减少了 4.5%,每个主机增加了 4.5 GB,从而使我们能够将每个主机上运行的进程数量从 64 增加到 66,从而增加了每个主机可以处理的请求数量并提高了 CPU 利用率,从而减少了我们的...

开通本站会员,查看完整译文。

ホーム - Wiki
Copyright © 2011-2025 iteam. Current version is 2.142.0. UTC+08:00, 2025-02-23 07:02
浙ICP备14020137号-1 $お客様$