Introduction
Workerman enables PHP developers to build long-running network services using pure PHP, no C extensions required. It supports millions of concurrent connections and is commonly used for real-time chat, push notifications, and IoT gateways.
What Workerman Does
- Runs persistent PHP processes for high-performance network services
- Supports TCP, UDP, HTTP, and WebSocket protocols natively
- Handles high concurrency through event-driven non-blocking I/O
- Provides timer, signal handling, and process management APIs
- Works as a foundation for real-time applications and microservices
Architecture Overview
Workerman uses a multi-process model with a master process that forks worker processes. Each worker runs an event loop (using libevent, event, or a built-in select fallback) that handles socket I/O without blocking. Connections are distributed across workers by the OS kernel, and each worker can handle thousands of simultaneous connections.
Self-Hosting & Configuration
- Install via Composer with
composer require workerman/workerman - Start workers with
php start.php start(use-dfor daemon mode) - Configure worker count with
$worker->count = 4 - Set transport to SSL/TLS for encrypted connections
- Monitor processes with
php start.php status
Key Features
- Zero C extension dependencies for basic usage
- Multi-process architecture with graceful reload
- Built-in HTTP and WebSocket server implementations
- Custom protocol support via simple interfaces
- Compatible with standard PHP libraries and Composer packages
Comparison with Similar Tools
- Swoole — C extension with coroutines; Workerman is pure PHP with event-driven callbacks
- ReactPHP — similar event-loop model; Workerman adds multi-process management built in
- Node.js — JavaScript event-driven runtime; Workerman offers the same model for PHP teams
- RoadRunner — Go-based process manager; Workerman stays fully within the PHP ecosystem
- Amphp — async PHP library; Workerman focuses on network server use cases specifically
FAQ
Q: Does Workerman require the Swoole extension? A: No. Workerman is pure PHP. It optionally uses the event or libevent extensions for better performance.
Q: Can Workerman run alongside PHP-FPM? A: Yes. Workerman runs as a separate process and can coexist with PHP-FPM on the same server.
Q: How many connections can Workerman handle? A: Workerman has been benchmarked handling over one million concurrent connections on a single server with appropriate OS tuning.
Q: Is Workerman suitable for production use? A: Yes. It is widely used in production for chat systems, game servers, and IoT platforms, particularly in the Chinese PHP ecosystem.