Skip to content

Commit 6aca8dd

Browse files
authored
[php] Phpixie add Adapterman variant (#10026)
1 parent 071bcd9 commit 6aca8dd

File tree

6 files changed

+134
-3
lines changed

6 files changed

+134
-3
lines changed

frameworks/PHP/phpixie/benchmark_config.json

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"database": "MySQL",
1515
"framework": "phpixie",
1616
"language": "PHP",
17-
"flavor": "PHP7",
17+
"flavor": "PHP8",
1818
"orm": "Full",
1919
"platform": "FPM/FastCGI",
2020
"webserver": "nginx",
@@ -23,6 +23,29 @@
2323
"display_name": "phpixie",
2424
"notes": "",
2525
"versus": "php"
26+
},
27+
"workerman": {
28+
"json_url": "/json",
29+
"db_url": "/db",
30+
"query_url": "/queries?queries=",
31+
"fortune_url": "/fortunes",
32+
"update_url": "/updates?queries=",
33+
"plaintext_url": "/plaintext",
34+
"port": 8080,
35+
"approach": "Realistic",
36+
"classification": "Fullstack",
37+
"database": "MySQL",
38+
"framework": "phpixie",
39+
"language": "PHP",
40+
"flavor": "PHP8",
41+
"orm": "Full",
42+
"platform": "workerman",
43+
"webserver": "none",
44+
"os": "Linux",
45+
"database_os": "Linux",
46+
"display_name": "phpixie [workerman]",
47+
"notes": "",
48+
"versus": "php"
2649
}
2750
}]
2851
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
opcache.enable=1
2+
opcache.enable_cli=1
3+
opcache.validate_timestamps=0
4+
opcache.save_comments=0
5+
opcache.enable_file_override=1
6+
opcache.memory_consumption=256
7+
opcache.interned_strings_buffer=16
8+
opcache.huge_code_pages=1
9+
10+
mysqlnd.collect_statistics = Off
11+
memory_limit = 512M
12+
13+
opcache.jit_buffer_size=128M
14+
opcache.jit=tracing
15+
16+
disable_functions=header,header_remove,headers_sent,headers_list,http_response_code,setcookie,session_create_id,session_id,session_name,session_save_path,session_status,session_start,session_write_close,session_regenerate_id,session_unset,session_get_cookie_params,session_set_cookie_params,set_time_limit
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM ubuntu:24.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null
6+
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
7+
RUN apt-get update -yqq > /dev/null && \
8+
apt-get install -yqq nginx git unzip php8.0 php8.0-common php8.0-cli php8.0-mysql php8.0-xml php8.0-curl > /dev/null
9+
10+
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
11+
12+
RUN apt-get install -y php-pear php8.0-dev libevent-dev > /dev/null
13+
RUN pecl install event-3.1.4 > /dev/null && echo "extension=event.so" > /etc/php/8.0/cli/conf.d/event.ini
14+
15+
COPY deploy/conf/adapterman.ini /etc/php/8.0/cli/conf.d/20-adapterman.ini
16+
17+
WORKDIR /phpixie
18+
COPY --link . .
19+
20+
RUN composer install --optimize-autoloader --classmap-authoritative --no-dev --quiet
21+
RUN composer require joanhey/adapterman:^0.6 --quiet
22+
23+
RUN chmod -R 777 /phpixie
24+
25+
EXPOSE 8080
26+
CMD php server.php start

frameworks/PHP/phpixie/phpixie.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

@@ -11,8 +11,8 @@ COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
1111

1212
COPY deploy/conf/* /etc/php/8.0/fpm/
1313

14-
ADD ./ /phpixie
1514
WORKDIR /phpixie
15+
COPY --link . .
1616

1717
RUN if [ $(nproc) = 2 ]; then sed -i "s|pm.max_children = 1024|pm.max_children = 512|g" /etc/php/8.0/fpm/php-fpm.conf ; fi;
1818

frameworks/PHP/phpixie/server.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
require_once __DIR__ . '/vendor/autoload.php';
3+
4+
5+
use Adapterman\Adapterman;
6+
use Workerman\Worker;
7+
use Workerman\Timer;
8+
9+
Adapterman::init();
10+
11+
$http_worker = new Worker('http://0.0.0.0:8080');
12+
$http_worker->count = (int) shell_exec('nproc') * 4;
13+
$http_worker->reusePort = true;
14+
$http_worker->name = 'AdapterMan Phpixie';
15+
16+
$http_worker->onWorkerStart = static function () {
17+
HeaderDate::init();
18+
//chdir(__DIR__.'/public');
19+
require 'web/start.php';
20+
};
21+
22+
$http_worker->onMessage = static function ($connection) {
23+
24+
$connection->send(run());
25+
};
26+
27+
Worker::runAll();
28+
29+
class HeaderDate
30+
{
31+
const NAME = 'Date: ';
32+
33+
/**
34+
* Date header
35+
*
36+
* @var string
37+
*/
38+
public static $date;
39+
40+
public static function init(): void
41+
{
42+
self::$date = self::NAME . gmdate(DATE_RFC7231);
43+
Timer::add(1, static function() {
44+
self::$date = self::NAME . gmdate(DATE_RFC7231);
45+
});
46+
}
47+
}

frameworks/PHP/phpixie/web/start.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
$root = dirname(__DIR__);
3+
$loader = require $root.'/vendor/autoload.php';
4+
$loader->add('', $root.'/classes/');
5+
6+
global $pixie;
7+
$pixie = new \App\Pixie();
8+
$pixie->bootstrap($root);
9+
10+
function run(): string
11+
{
12+
global $pixie;
13+
ob_start();
14+
15+
$pixie->handle_http_request();
16+
header(HeaderDate::$date); // To pass the bench, nginx auto add it
17+
18+
return ob_get_clean();
19+
}

0 commit comments

Comments
 (0)