Download the PHP package modelslab/octane-coroutine without Composer

On this page you can find all versions of the php package modelslab/octane-coroutine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package octane-coroutine

Laravel Octane with Swoole Coroutine Support

โšก High-performance Laravel with true coroutine support for massive concurrency

Packagist Version Packagist Downloads PHP Version Laravel Swoole

Requires the latest Swoole with coroutine hooks enabled. Older versions are not supported.

๐Ÿš€ What is this?

This is an enhanced fork of Laravel Octane that adds true Swoole coroutine support, enabling your Laravel application to handle thousands of concurrent requests efficiently through non-blocking I/O.

Performance Highlights

โšก The Problem with Standard Octane

Standard Octane uses a "One Worker = One Request" model. When a request performs blocking I/O (database queries, API calls, file operations), the entire worker is blocked:

With 1-second blocking operations, this means only ~8 requests/second throughput.

๐ŸŽฏ The Solution: Runtime Coroutine Hooks

This fork enables Swoole's coroutine runtime hooks (SWOOLE_HOOK_ALL), which automatically converts PHP's blocking functions into non-blocking, coroutine-safe versions:

With the same 1-second blocking operations, this achieves 2,773+ requests/second โ€” a 360ร— improvement!

What Gets Hooked?

๐Ÿ“ฆ Installation

Install via Composer from Packagist:

Then install Octane with Swoole:

Specific Version

Updating the Package

Tip: Pin your production deployments to specific versions:

๐Ÿ”ง Configuration

The package works out-of-the-box with sensible defaults. Coroutines are enabled by default with runtime hooks.

Worker Configuration

Start with appropriate worker count:

Advanced Configuration

Edit config/octane.php if needed:

Redis & Database Coroutine Safety

Coroutine mode relies on coroutine-safe IO drivers and connection handling. Recommended defaults:

Notes:

v0.8.7 Production Hardening

Version v0.8.7 includes the production hardening used for high-concurrency AI API workloads:

Regression coverage for this release includes concurrent request isolation, nested API shape preservation, request-time container binding isolation, locale/translator isolation, Redis manager isolation, dirty DB transaction cleanup, and DB idle pruning.

Validated Stress Results

The v0.8.7 release was validated in Docker with host-network MySQL and Redis:

After stress, MySQL and Redis returned to baseline (Threads_connected=1, connected_clients=1) with no container log stack traces.

๐ŸŠ Understanding Workers and Coroutines

This section clarifies the key concepts that make this fork different from standard Octane.

What are Workers?

Workers are OS-level processes spawned by Swoole. Each worker:

What are Coroutines?

Coroutines are lightweight, cooperative "threads" managed by Swoole at the application level (not OS-level). When a coroutine encounters blocking I/O, it yields control to other coroutines instead of blocking the entire worker.

How They Work Together

How Request Isolation Works

This runtime does not use an HTTP application pool anymore. Each Swoole worker boots one shared Laravel worker runtime, and concurrent requests are isolated by the coroutine-aware container proxy plus per-request scoped state for bindings such as request, session, router, view, log, cache, and Redis managers.

The legacy octane.swoole.pool config namespace remains only for db_max_connections_buffer, which is used by a startup safety warning.

๐Ÿงช Testing

Unit tests require a PHP build with the Swoole extension installed.

Coroutine Runtime Configuration

The package is pool-free for HTTP workers. The relevant Swoole config looks like:

OCTANE_POOL_DB_MAX_CONNECTIONS_BUFFER only affects the startup warning that checks MySQL max_connections against your configured database pool minimums.

โšก Performance Optimization

CPU Usage and Tick Timers

Following Hyperf/Swoole best practices, this fork disables tick timers by default to prevent unnecessary CPU usage.

What are Tick Timers?

Octane can dispatch "tick" events to task workers every second. However:

Why Disable Tick?

In earlier configurations, tick timers with --task-workers=auto would create one task worker per CPU core (e.g., 12 workers on a 12-core system). Even with no traffic:

This causes high CPU usage even when the server is idle!

When to Enable Tick

Only enable tick if you have listeners for TickReceived or TickTerminated events that need to run periodically:

Then start with minimal task workers (not auto):

Task Worker Guidelines

Scenario Recommended --task-workers
Tick disabled (default) 0 (auto)
Tick enabled 1 or 2
Heavy async task dispatch 2 to 4
Never use auto (causes CPU overhead)

๐Ÿ“Š Performance Benchmarks

Real-world load testing results with wrk:

Baseline (No Coroutines)

With Coroutines Enabled

Per-Worker Efficiency

Configuration Req/sec per worker Concurrent requests per worker
Standard Octane ~1 1
With Coroutines ~87 ~87

Each worker can efficiently handle ~87 concurrent requests thanks to coroutines!

๐Ÿ—๏ธ Architecture

Runtime Hooks

Enabled automatically on worker start:

This converts all blocking I/O to coroutine-safe operations without any code changes required.

Worker Initialization

Workers log their initialization for monitoring:

Graceful Degradation

If a worker isn't ready, requests receive 503 responses until initialization completes:

๐ŸŽฏ When to Use This Fork

โœ… Perfect For:

โš ๏ธ Standard Octane is Fine For:

๐Ÿ” Monitoring

Worker Logs

Check worker initialization in your logs:

Performance Metrics

Monitor your application:

๐Ÿ› ๏ธ Production Recommendations

Resource Planning

Example: 32 workers = 3.2-6.4GB RAM

OS Tuning

For high concurrency (10,000+ connections):

Swoole Configuration

For extreme load:

๐Ÿ› Debugging

Enable debug logging to track worker behavior:

โš ๏ธ Important Notes

๐Ÿ“ˆ Scaling Guide

Small (Development)

Medium (Production)

Large (High-Traffic)

XL (Enterprise)

๐ŸŽฏ Recommended Configuration: 8-Core CPU for 10K req/sec

This section provides specific, tested recommendations for achieving 10,000 requests/second on an 8-core CPU.

Understanding the Math

Recommended Configuration

Start Command

Resource Requirements

Resource Minimum Recommended
CPU 8 cores 8+ cores
RAM 8GB 16GB
File Descriptors 65536 100000+
Network 1Gbps 10Gbps

Memory Calculation

Database Connection Pooling

Database pooling is separate from the HTTP runtime. Size it from worker count and your configured per-connection pool minimums and maximums.

For example, 8 workers ร— min_connections=1 means at least 8 DB connections before real traffic. OCTANE_POOL_DB_MAX_CONNECTIONS_BUFFER only adjusts the startup warning threshold for this planning.

Or configure MySQL server:

OS Tuning for 10K req/sec

Benchmark Expectations

With the above configuration on 8-core CPU:

Scenario Expected req/sec
Simple JSON response 15,000-20,000
Database SELECT (cached) 8,000-12,000
Database SELECT (no cache) 3,000-6,000
External API call (100ms) 8,000-10,000
Complex business logic 5,000-8,000

Tuning Tips

  1. Start Conservative: Begin with a modest worker count and measure under load
  2. Monitor Actively: Watch memory, 5xx rates, worker restarts, and upstream saturation
  3. Warm Up: Allow 30-60 seconds for workers to warm up before heavy traffic
  4. Use Redis: Offload sessions and cache to Redis for better concurrency
  5. Size Database Pools Separately: Prevent DB connection exhaustion independently of HTTP concurrency

๐Ÿ“š Resources

๐Ÿค Contributing

Contributions are welcome! Please read the contribution guide.

๐Ÿ”’ Security

Please review our security policy to report vulnerabilities.

๐Ÿ“„ License

This fork maintains the original MIT license. See LICENSE.md.


Built with โค๏ธ by ModelsLab

Original Laravel Octane by Taylor Otwell and the Laravel team


All versions of octane-coroutine with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1.0
hyperf/context Version ^3.1
hyperf/pool Version ^3.1
laminas/laminas-diactoros Version ^3.0
laravel/framework Version ^10.10.1|^11.0|^12.0
laravel/prompts Version ^0.1.24|^0.2.0|^0.3.0
laravel/serializable-closure Version ^1.3|^2.0
nesbot/carbon Version ^2.66.0|^3.0
symfony/console Version ^6.0|^7.0
symfony/psr-http-message-bridge Version ^2.2.0|^6.4|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package modelslab/octane-coroutine contains the following files

Loading the files please wait ...