Browse Source

Update ubiquity-react (#4820)

* Remove logging + increase workers + getById

* Update Db.php

* Update Json.php

* Add transactions

* update readme + 8080 port
jcheron 6 years ago
parent
commit
41d0cdd61f

+ 1 - 1
frameworks/PHP/ubiquity/.ubiquity/react-config.php

@@ -1,5 +1,5 @@
 <?php
 return array(
 	"host" => "0.0.0.0",
-	"port" => 8090
+	"port" => 8080
 );

+ 6 - 1
frameworks/PHP/ubiquity/README.md

@@ -15,7 +15,7 @@ The tests are separated into 4 controllers:
   * [DB](app/controllers/Db.php)
   * [QUERY](app/controllers/Db.php)
   * [CACHED QUERY (not implemented)]()
-  * [UPDATE](app/controllers/Db.php)
+  * [UPDATE](app/controllers/Db.php) Utilizes transactions
 - `Fortunes` for using the internal template engine
   * [FORTUNES](app/controllers/Fortunes.php)
 - `Plaintext` for plaintext response
@@ -32,6 +32,11 @@ The tests were run with:
 * [Ubiquity-php-pm bridge](https://github.com/phpMv/ubiquity-php-pm)
 * [MySQL 5.7](https://dev.mysql.com/)
 
+## Servers
+PHP-PM server (beta version) is configured with this values:
+- workers: 32
+- max-requests: 1024
+
 ## Test URLs
 ### JSON
 

+ 19 - 18
frameworks/PHP/ubiquity/app/controllers/Db.php

@@ -7,40 +7,41 @@ use models\World;
 use Ubiquity\controllers\Startup;
 use Ubiquity\utils\http\UResponse;
 
-
 /**
  * Bench controller.
- **/
-class Db extends Controller{
-	public function initialize(){
-		UResponse::setContentType( 'application/json' );
+ */
+class Db extends Controller {
+
+	public function initialize() {
+		UResponse::setContentType('application/json');
 	}
 
 	public function index() {
-		$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
-		echo json_encode($world->_rest);
+		$world = DAO::getById(World::class, mt_rand(1, 10000), false);
+		echo \json_encode($world->_rest);
 	}
-	
+
 	public function query($queries = 1) {
 		$worlds = [];
 		$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
-		for ($i = 0; $i < $queries; ++$i) {
-			$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
-			$worlds[]=$world->_rest;
+		for ($i = 0; $i < $queries; ++ $i) {
+			$world = DAO::getById(World::class, mt_rand(1, 10000), false);
+			$worlds[] = $world->_rest;
 		}
-		echo json_encode($worlds);
+		echo \json_encode($worlds);
 	}
-	
+
 	public function update($queries = 1) {
 		$worlds = [];
 		$queries = is_numeric($queries) ? min(max($queries, 1), 500) : 1;
-		for ($i = 0; $i < $queries; ++$i) {
-			$world=DAO::getOne(World::class, mt_rand(1, 10000),false);
+		DAO::beginTransaction();
+		for ($i = 0; $i < $queries; ++ $i) {
+			$world = DAO::getById(World::class, mt_rand(1, 10000), false);
 			$world->setRandomNumber(mt_rand(1, 10000));
 			DAO::update($world);
-			$worlds[]=$world->_rest;
+			$worlds[] = $world->_rest;
 		}
-		echo json_encode($worlds);
+		DAO::commit();
+		echo \json_encode($worlds);
 	}
-
 }

+ 9 - 5
frameworks/PHP/ubiquity/app/controllers/Json.php

@@ -6,12 +6,16 @@ use Ubiquity\utils\http\UResponse;
 
 /**
  * Json controller.
- **/
-class Json extends Controller{
+ */
+class Json extends Controller {
+
 	public function initialize() {
-		UResponse::setContentType( 'application/json' );
+		UResponse::setContentType('application/json');
 	}
-	public function index(){
-		echo \json_encode(['message' => 'Hello, World!']);
+
+	public function index() {
+		echo \json_encode([
+			'message' => 'Hello, World!'
+		]);
 	}
 }

+ 1 - 1
frameworks/PHP/ubiquity/benchmark_config.json

@@ -32,7 +32,7 @@
         "update_url": "/Db/update/",
         "query_url": "/Db/query/",
         "fortune_url": "/Fortunes",
-        "port": 8090,
+        "port": 8080,
         "approach": "Realistic",
         "classification": "Fullstack",
         "database": "MySQL",

+ 1 - 1
frameworks/PHP/ubiquity/ubiquity-react.dockerfile

@@ -26,4 +26,4 @@ RUN chmod 777 -R /ubiquity/.ubiquity/*
 
 RUN chmod 777 /ubiquity/vendor/bin/ppm
 
-CMD /ubiquity/vendor/bin/ppm --bridge='\PHPPM\Ubiquity' --bootstrap='\PHPPM\Ubiquity' start --debug 0 --workers 16 --host=0.0.0.0 --port=8090
+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