Skip to content

Commit 41d0cdd

Browse files
jcheronNateBrady23
authored andcommitted
Update ubiquity-react (#4820)
* Remove logging + increase workers + getById * Update Db.php * Update Json.php * Add transactions * update readme + 8080 port
1 parent c322561 commit 41d0cdd

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22
return array(
33
"host" => "0.0.0.0",
4-
"port" => 8090
4+
"port" => 8080
55
);

frameworks/PHP/ubiquity/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The tests are separated into 4 controllers:
1515
* [DB](app/controllers/Db.php)
1616
* [QUERY](app/controllers/Db.php)
1717
* [CACHED QUERY (not implemented)]()
18-
* [UPDATE](app/controllers/Db.php)
18+
* [UPDATE](app/controllers/Db.php) Utilizes transactions
1919
- `Fortunes` for using the internal template engine
2020
* [FORTUNES](app/controllers/Fortunes.php)
2121
- `Plaintext` for plaintext response
@@ -32,6 +32,11 @@ The tests were run with:
3232
* [Ubiquity-php-pm bridge](https://github.com/phpMv/ubiquity-php-pm)
3333
* [MySQL 5.7](https://dev.mysql.com/)
3434

35+
## Servers
36+
PHP-PM server (beta version) is configured with this values:
37+
- workers: 32
38+
- max-requests: 1024
39+
3540
## Test URLs
3641
### JSON
3742

frameworks/PHP/ubiquity/app/controllers/Db.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,41 @@
77
use Ubiquity\controllers\Startup;
88
use Ubiquity\utils\http\UResponse;
99

10-
1110
/**
1211
* Bench controller.
13-
**/
14-
class Db extends Controller{
15-
public function initialize(){
16-
UResponse::setContentType( 'application/json' );
12+
*/
13+
class Db extends Controller {
14+
15+
public function initialize() {
16+
UResponse::setContentType('application/json');
1717
}
1818

1919
public function index() {
20-
$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
21-
echo json_encode($world->_rest);
20+
$world = DAO::getById(World::class, mt_rand(1, 10000), false);
21+
echo \json_encode($world->_rest);
2222
}
23-
23+
2424
public function query($queries = 1) {
2525
$worlds = [];
2626
$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
27-
for ($i = 0; $i < $queries; ++$i) {
28-
$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
29-
$worlds[]=$world->_rest;
27+
for ($i = 0; $i < $queries; ++ $i) {
28+
$world = DAO::getById(World::class, mt_rand(1, 10000), false);
29+
$worlds[] = $world->_rest;
3030
}
31-
echo json_encode($worlds);
31+
echo \json_encode($worlds);
3232
}
33-
33+
3434
public function update($queries = 1) {
3535
$worlds = [];
3636
$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
37-
for ($i = 0; $i < $queries; ++$i) {
38-
$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
37+
DAO::beginTransaction();
38+
for ($i = 0; $i < $queries; ++ $i) {
39+
$world = DAO::getById(World::class, mt_rand(1, 10000), false);
3940
$world->setRandomNumber(mt_rand(1, 10000));
4041
DAO::update($world);
41-
$worlds[]=$world->_rest;
42+
$worlds[] = $world->_rest;
4243
}
43-
echo json_encode($worlds);
44+
DAO::commit();
45+
echo \json_encode($worlds);
4446
}
45-
4647
}

frameworks/PHP/ubiquity/app/controllers/Json.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66

77
/**
88
* Json controller.
9-
**/
10-
class Json extends Controller{
9+
*/
10+
class Json extends Controller {
11+
1112
public function initialize() {
12-
UResponse::setContentType( 'application/json' );
13+
UResponse::setContentType('application/json');
1314
}
14-
public function index(){
15-
echo \json_encode(['message' => 'Hello, World!']);
15+
16+
public function index() {
17+
echo \json_encode([
18+
'message' => 'Hello, World!'
19+
]);
1620
}
1721
}

frameworks/PHP/ubiquity/benchmark_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"update_url": "/Db/update/",
3333
"query_url": "/Db/query/",
3434
"fortune_url": "/Fortunes",
35-
"port": 8090,
35+
"port": 8080,
3636
"approach": "Realistic",
3737
"classification": "Fullstack",
3838
"database": "MySQL",

frameworks/PHP/ubiquity/ubiquity-react.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
2626

2727
RUN chmod 777 /ubiquity/vendor/bin/ppm
2828

29-
CMD /ubiquity/vendor/bin/ppm --bridge='\PHPPM\Ubiquity' --bootstrap='\PHPPM\Ubiquity' start --debug 0 --workers 16 --host=0.0.0.0 --port=8090
29+
CMD /ubiquity/vendor/bin/ppm --bridge='\PHPPM\Ubiquity' --bootstrap='\PHPPM\Ubiquity' start --debug 0 --logging 0 --workers 32 --max-requests 1024 --host=0.0.0.0 --port=8080

0 commit comments

Comments
 (0)