惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
量子位
S
SegmentFault 最新的问题
博客园 - 聂微东
博客园 - 【当耐特】
J
Java Code Geeks
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
H
Help Net Security
V
V2EX
人人都是产品经理
人人都是产品经理
博客园 - Franky
罗磊的独立博客
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
PHP is 5x Faster Than NestJS? Rethinking High-Load with S...
Roman Shneer · 2026-05-09 · via DEV Community

Roman Shneer

For years, the industry consensus was clear: if you need high concurrency, non-blocking I/O, and microservices, you choose Node.js (NestJS) or Go. PHP was labeled as the "old-school" language, hindered by its "request-response" lifecycle and the overhead of booting the framework for every single hit.

I decided to challenge that stereotype.

I built a production-ready High-Load Event Processor capable of handling 10,000+ RPS using PHP 8.4 and Swoole. In my stress tests, this architecture consistently outperformed equivalent NestJS setups by nearly 5x in throughput, while maintaining a significantly lower latency floor.

The Problem with the Status Quo

Traditional PHP (FPM) is like a restaurant that hires and fires its entire staff every time a customer walks in. It’s reliable but inefficient for high-frequency event ingestion. Node.js improved this with a persistent event loop, but even the V8 engine has its limits when managing tens of thousands of concurrent Promises.

Why Swoole Changes Everything

Swoole isn't just a library; it’s a C-native coroutine engine that transforms PHP into a high-performance, persistent-memory powerhouse. Here is why it crushed the competition in my benchmarks:

1. C-Native Coroutines vs. The Event Loop
While NestJS relies on the JavaScript Event Loop and async/await overhead, Swoole introduces user-space threads (coroutines) managed at the C level. Context switching happens only during I/O operations, with far less CPU overhead than managing the Promise lifecycle in V8.

2. Persistent State & Zero Cold Starts
The application boots once. Database connections, configurations, and pre-compiled code stay in memory. This eliminates the "bootstrap tax" and allows for lightning-fast execution.

3. Native Connection Pooling
One of the biggest bottlenecks in high-load systems is the database. In my project, I implemented Swoole-native Connection Pooling for PostgreSQL and Redis. Unlike standard Node.js drivers that can struggle under extreme concurrency, Swoole handles thousands of active connections with minimal memory footprint.

The Architecture: 10,000 Requests Per Second

My system uses a multi-layered approach to ensure Zero Data Loss:

  • Ingestion: A Swoole HTTP server receives events and pushes them into a Redis buffer using non-blocking coroutines.
  • Buffering: Redis acts as a high-speed shock absorber for traffic spikes.
  • Processing: Dedicated workers pull batches from Redis and persist them to PostgreSQL using optimized write-pipelines.

The Results

Using Artillery for load testing, the results were undeniable:

  • Throughput: Stable 10k+ RPS on standard hardware.
  • Latency: p95 remained flat even as concurrency scaled.
  • Reliability: 0% packet loss, thanks to the asynchronous pipeline.

Conclusion: Is PHP Back?

PHP never left, but it has evolved. With Swoole, we no longer have to trade the rapid development cycle of PHP for the performance of Go or Node.js. We can have both.

If you are building microservices in 2026 and performance is your priority, it’s time to stop looking at PHP in the rearview mirror and start looking at what it can do with Swoole.

PHP stress test

artillery run performance/main.yml

Enter fullscreen mode Exit fullscreen mode

PHP/Swoole artillery - stress test

NestJS stress test

artillery run performance/main.yml

Enter fullscreen mode Exit fullscreen mode

NestJS artillery - stress test

PHP/Swoole Insert 1million records

artillery run performance/insert1m.yml

Enter fullscreen mode Exit fullscreen mode

PHP/Swoole artillery - Insert 1million records test

NestJs Insert 1 million records

artillery run performance/insert1m.yml

Enter fullscreen mode Exit fullscreen mode

NestJs artillery - Insert 1 million records test

🔗 Check out the full source code and benchmarks on my GitHub:

PHP/Swoole: https://github.com/roman-shneer/high-load-event-processor-php

NestJS: https://github.com/roman-shneer/high-load-event-processor