Overview
Swoole variant images extend the Alpine-based images with the Swoole PHP extension, enabling asynchronous, concurrent, and high-performance network applications. Swoole provides coroutine-based concurrency, async I/O, and built-in HTTP/WebSocket servers.Swoole images are built on top of Alpine base images, inheriting all SQL Server drivers and PHP extensions while adding Swoole capabilities.
What is Swoole?
Swoole is an asynchronous programming framework for PHP that provides:Coroutines
Lightweight concurrent execution without callback hell
Async I/O
Non-blocking I/O operations for high concurrency
Built-in Servers
HTTP, WebSocket, TCP, and UDP servers out of the box
Performance
Handle thousands of concurrent connections efficiently
Available Tags
- PHP 8.4
- PHP 8.3
- PHP 8.2
- PHP 8.1
namoshek/php-mssql:8.4-cli-alpine-swoolenamoshek/php-mssql:8.4-fpm-alpine-swoole
What’s Included
Swoole images include everything from Alpine base images plus:Swoole Extension
The Swoole PHP extension is added on top of the base Alpine image:Complete Feature Set
All features from Alpine images are included:- SQL Server
- PHP Extensions
- Dev Tools (CLI)
- System Tools
- Microsoft ODBC Driver 18
- mssql-tools18 (sqlcmd, bcp)
- sqlsrv and pdo_sqlsrv extensions
When to Use Swoole
Real-time Applications
WebSocket servers, chat applications, live dashboards
Microservices
High-performance API gateways and service meshes
Long-running Processes
Background workers, queue processors, schedulers
High Concurrency
Applications handling thousands of simultaneous connections
Swoole Capabilities
HTTP Server
Create a high-performance HTTP server without nginx or Apache:WebSocket Server
Build real-time WebSocket applications:Coroutines
Handle concurrent operations elegantly:Usage Examples
Laravel Octane Support
Swoole images work perfectly with Laravel Octane:Image Size
Swoole adds minimal overhead to Alpine images:- CLI images: ~270-320 MB (+~20MB vs Alpine)
- FPM images: ~220-270 MB (+~20MB vs Alpine)
Performance Comparison
Traditional PHP-FPM
~1,000 requests/second with 100 concurrent connections
Swoole HTTP Server
~10,000+ requests/second with 1,000+ concurrent connections
Actual performance depends on your application logic, database queries, and server hardware. Swoole excels at I/O-bound operations.
Important Considerations
Process Persistence
Process Persistence
Unlike PHP-FPM, Swoole keeps your application in memory between requests. This means:
- Faster response times (no bootstrap overhead)
- Shared state possible (use with caution)
- Memory leaks can accumulate
- Database connections should be managed carefully
Code Reloading
Code Reloading
Changes to PHP files don’t take effect automatically. You must:
- Restart the Swoole server to see changes
- Use hot-reload tools in development
- Implement proper deployment strategies
Global State
Global State
Global variables persist between requests:
- Be careful with static variables
- Reset state as needed
- Use Swoole’s context API for request-specific data
Compatibility
Compatibility
Not all PHP libraries work well with Swoole:
- Most pure PHP code works fine
- Libraries using blocking I/O may reduce performance
- Frameworks like Laravel Octane are designed for Swoole
- Test thoroughly with your dependencies
Debugging and Monitoring
Learning Resources
Swoole Documentation
Official Swoole documentation and guides
Laravel Octane
Laravel’s first-party Swoole integration
Hyperf Framework
Modern PHP framework built for Swoole
Swoole GitHub
Source code and examples
Next Steps
Alpine Images
Learn about the base Alpine images
SQL Server Connection
Connect to SQL Server with Swoole
PHP Configuration
Configure PHP and Swoole settings
Examples
More container usage examples
