spatie/laravel-dynamic-servers
Composer 安装命令:
composer require spatie/laravel-dynamic-servers
包简介
Dynamically create and destroy servers
README 文档
README
Dynamically create and destroy servers
This package can help you start and stop servers when you need them. The prime use case is to spin up extra working servers that can help you process the workload on queues.
You can think of this as a sort of PHP based version of Kubernetes that has 5% of its features, but covers that 80% use case. For most PHP and Laravel developers, this package will also be easier to learn and use.
Typically, on your hosting provider, you would prepare a server snapshot, that will be used as a template when starting new servers.
After the package is configured, spinning up an extra servers is as easy as:
// typically, in a service provider use Laravel\Horizon\WaitTimeCalculator; use Spatie\DynamicServers\Facades\DynamicServers; use Spatie\DynamicServers\Support\DynamicServersManager; /* * The package will call the closure passed * to `determineServerCount` every minute */ DynamicServers::determineServerCount(function(DynamicServersManager $servers) { /* * First, we'll calculate the number of servers needed. * * In this example, we will take a look at Horizon's * reported waiting time. Of course, in your project you can * calculate the number of servers needed however you want. */ $waitTimeInMinutes = app(WaitTimeCalculator::class)->calculate('default'); $numberOfServersNeeded = round($waitTimeInMinutes / 10); /* * Next, we will pass the number of servers needed to the `ensure` method. * * If there currently are less that that number of servers available, * the package will start new ones. * * If there are currently more than that number of servers running, * the package will stop a few servers. */ $servers->ensure($numberOfServersNeeded); });
Out of the box, the package supports UpCloud. You can create your own server provider to add support for your favourite hosting service.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Documentation
All documentation is available on our documentation site.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
This idea behind this package was... spawned 🥁 by streams and a blog post by Jason McCreary on Spawning workers based on queue workload.
License
The MIT License (MIT). Please see License File for more information.
spatie/laravel-dynamic-servers 适用场景与选型建议
spatie/laravel-dynamic-servers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.97k 次下载、GitHub Stars 达 235, 最近一次更新时间为 2022 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「spatie」 「laravel-dynamic-servers」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spatie/laravel-dynamic-servers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spatie/laravel-dynamic-servers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spatie/laravel-dynamic-servers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Receive webhooks in Laravel apps
Easily optimize images using PHP
Store your application settings
Alfabank REST API integration
Add tags and taggable behaviour to your Laravel app
Speed up a Laravel application by caching the entire response additions
统计信息
- 总下载量: 12.97k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 235
- 点击次数: 22
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-27