craftix/swoole-requester 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

craftix/swoole-requester

最新稳定版本:v1.0.0

Composer 安装命令:

composer require craftix/swoole-requester

包简介

A PHP Swoole package to run HTTP request stress tests.

README 文档

README

A PHP-based HTTP client stress tester built with Swoole. This package allows you to send concurrent requests to an HTTP server for performance testing.

Features

  • Concurrency: Supports configurable concurrency for sending multiple requests simultaneously.
  • Request Count: Allows defining the number of requests to be sent in the stress test.
  • Timeouts: Customizable request timeout settings.
  • SSL Handling: Option to disable SSL verification for HTTP requests.
  • Performance Metrics: Tracks success, failure, throughput, and duration of the requests.

Requirements

  • PHP >= 8.2
  • Swoole extension >= 4.5.0
  • Composer

Installation

Step 1: Install the dependencies

Install the project via Composer:

 composer require craftix/requester

Usage

Run test with php

Create a PHP file named stress-test.php and copy the code below:

use Craftix\Requester\Config;
use Craftix\Requester\Requester;


$config = Config::create()
    ->setHost('127.0.0.1') // The target host to send requests to (e.g., 'google.com')
    ->setPort(8040) // The target port to use for requests (default is 443 for HTTPS)
    ->setPath('/') // The path for the HTTP request (e.g., '/' for the root page)
    ->setRequestCount(1000) // The total number of requests to send during the stress test
    ->setConcurrency(50) // The number of concurrent requests to send at a time
    ->setRequestTimeout(2) // The timeout duration (in seconds) for each request
    ->disableSsl(); // Disable SSL verification (useful for testing against servers with invalid SSL certificates)


/**
 * Run Stress Test
 */
Requester::run($config);

Run php test file

 php ./stress-test.php

Run test with docker

Run stress test with docker

 docker build -t swoole-requester ./vendor/craftix/
 docker run swoole-requester

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固