承接 php-lrpm/php-lrpm-cluster 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

php-lrpm/php-lrpm-cluster

Composer 安装命令:

composer require php-lrpm/php-lrpm-cluster

包简介

PHP Long Running Process Manager Cluster

README 文档

README

Clustering support for PHP-LRPM, including different sharding strategies.

Usage

You should extend the abstract PHPLRPM\Cluster\ShardingConfigurationSource class and implement a nullary (zero-argument) constructor which will be initializing instances of PHPLRPM\ConfigurationSource, PHPLRPM\Cluster\Providers\ClusterConfigurationProvider and PHPLRPM\Cluster\Filters\ShardingConfigurationFilter:

namespace MyNamespace;
use PHPLRPM\Cluster\ShardingConfigurationSource;

class MyLRPMWorkerShardingConfiguration extends ShardingConfigurationSource
{
    public function __construct()
    {
        //instance of PHPLRPM\ConfigurationSource
        $this->confSource = new MyLRPMWorkerConfiguration()
        //instance of PHPLRPM\Cluster\Providers\ClusterConfigurationProvider
        $this->clusterConfProvider = new EnvironmentBasedClusterConfigurationProvider();
        //instance of PHPLRPM\Cluster\Filters\ShardingConfigurationFilter
        $this->configurationFilter = new BalancedShardingConfigurationFilter();
    }
}

Then you may provide MyLRPMWorkerShardingConfiguration as a regular ConfigurationSource for PHP-LRPM, e.g.

lrpm '\MyNamespace\MyLRPMWorkerShardingConfiguration'

See https://github.com/vrza/php-lrpm#usage for more details.

Sharding Strategies

You can either write your own ShardingConfigurationFilter or use one of the built-in filters.

Balanced

Use the BalancedShardingConfigurationFilter when either:

  • scaling involves restarting the entire cluster

  • perfect load balancing is necessary

Pros Cons

Perfect load balancing

Potentially large number of disrupted processes when rescaling

Rendezvous Hashing

Use the RendezvousHashingShardingConfigurationFilter when both:

  • minimal worker process disruption is highly desirable

  • load balancing biased towards certain nodes is tolerable

Pros Cons

Minimal disruption when rescaling

Biased load balancing

Simple hashing

Use the HashingShardingConfigurationFilter to achieve:

  • decent (but not perfect) load balancing

  • some (but not complete) worker process disruption when cluster is rescaled

Pros Cons

Strikes a balance between load balancing and disruption

Guarantees neither perfect load balancing nor minimal disruption

Cluster Configuration and Providers

Cluster configuration parameters are

  • total number of nodes in the cluster

  • zero-based index of current node

You can either write your own ClusterConfigurationProvider or use one of the built-in providers.

Environment-based Cluster Configuration Provider

Use the EnvironmentBasedClusterConfigurationProvider to load cluster configuration from environment variables PHP_LRPM_NUMBER_OF_INSTANCES and PHP_LRPM_INSTANCE_NUMBER. Default variable names can be overridden.

File-based Cluster Configuration Provider

Use the FileBasedClusterConfigurationProvider to load cluster configuration from a JSON configuration file, e.g.:

{
    "numberOfInstances": 3,
    "instanceNumber" : 2
}

Installation

Assuming you have PHP Composer installed, and that the composer executable is in your $PATH:

composer require php-lrpm/php-lrpm-cluster

php-lrpm/php-lrpm-cluster 适用场景与选型建议

php-lrpm/php-lrpm-cluster 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.8k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 03 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「process」 「manager」 「cluster」 「long-running」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 php-lrpm/php-lrpm-cluster 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 php-lrpm/php-lrpm-cluster 我们能提供哪些服务?
定制开发 / 二次开发

基于 php-lrpm/php-lrpm-cluster 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-03-26