This project tests a way to speed up PHP web applications by offloading slow network calls to a different layer. The key insight is simple: when PHP makes a request to another server (like fetching data from an API), it has to sit and wait for that data to come back. During that wait time, the PHP process is blocked and can't handle other requests. This project measures how much faster you can serve users if you move those blocking calls elsewhere. The approach uses a web server called OpenResty, which includes a scripting layer called Lua that sits in front of PHP. Instead of having PHP make the slow network call directly, Lua makes the call asynchronously, meaning it doesn't block. The network request happens in the background while the web server continues handling other user requests. Once the data arrives, it gets combined with the PHP response and sent to the user. From the user's perspective, everything is faster because the server isn't wasting time sitting idle. The test results show real performance gains. When calling a backend server with 10 milliseconds of latency, the traditional PHP approach handles about 300 requests per second, while the Lua-based async approach handles 500, a 60% improvement. The difference is even more dramatic with higher latency backends: at 30ms latency, you go from 150 to 300 requests per second. This matters for anyone running a high-traffic website where every bit of efficiency counts, a faster application means serving more users with the same hardware, or spending less on servers. The tradeoff is architectural complexity. Instead of everything happening in one PHP process, you now have multiple layers (web server, Lua, PHP, and backend services) that need to coordinate. You also need OpenResty and PHP-FPM running together, plus the APC cache extension. For small sites this overhead might not be worth it, but for platforms handling thousands of concurrent users, particularly those making many external API calls, this pattern can significantly reduce infrastructure costs.
← hugozhu on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.