I manage to increase the phalcon and just use the bare setup but still 80req/s and 1k+req/s difference. is there any setup that should be followed?
Here is my basic setup in phalcon
$routes = new MicroCollection();
$routes->setHandler("App\Controllers\Frontend\HomeController", true);
$routes->get("/test", "get_test");
$app->mount($routes);
=================================
<?php
namespace App\Controllers\Frontend;
use App\Models\Users;
class HomeController extends \Phalcon\Mvc\Controller
{
public function get_test(){
$usr = new Users();
$usr = $usr->get_test();
var_dump($usr);
exit();
}
}
==================================
<?php
namespace App\Models;
use Phalcon\DI;
class Users extends \Phalcon\Mvc\Model {
public function getSource() {
return "users";
}
public function get_test(){
$sql = "SELECT * FROM users
ORDER BY user_id DESC LIMIT 12
OFFSET 1";
$di = $this->DI;
$db = $di['db'];
$data = $db->query($sql);
$result = $data->setFetchMode(\Phalcon\Db::FETCH_OBJ);
$results = $data->fetchAll();
return $results;
}
}
===========================================================
Phalcon result
[email protected]:~$ ab -n 200 -c 100 https://phalcon.dev/test/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, https://www.zeustech.net/
Licensed to The Apache Software Foundation, https://www.apache.org/
Benchmarking phalcon.dev (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests
Server Software: nginx
Server Hostname: phalcon.dev
Server Port: 80
Document Path: /test/
Document Length: 0 bytes
Concurrency Level: 100
Time taken for tests: 2.469 seconds
Complete requests: 200
Failed requests: 0
Total transferred: 26000 bytes
HTML transferred: 0 bytes
Requests per second: 81.00 [#/sec] (mean)
Time per request: 1234.613 [ms] (mean)
Time per request: 12.346 [ms] (mean, across all concurrent requests)
Transfer rate: 10.28 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 1.3 2 3
Processing: 267 994 289.1 1081 1474
Waiting: 267 994 289.1 1081 1474
Total: 269 995 288.8 1081 1477
Percentage of the requests served within a certain time (ms)
50% 1081
66% 1156
75% 1183
80% 1199
90% 1251
95% 1360
98% 1447
99% 1460
100% 1477 (longest request)
[email protected]:~$
Flask
route
app.add_url_rule('/<name>', view_func=LazyView('controllers.frontend.homepage.homename'))
user model
from config.database import db
class Users(db.Model):
__tablename__ = 'users'
user_id = db.Column(db.Integer, primary_key=True)
user_avatar = db.Column(db.String(255))
user_name = db.Column(db.String(255))
def __repr__(self):
return '<User %r>' % self.user_id
def raw_insert_sample():
db.engine.execute("""\
INSERT INTO users (user_avatar, user_name)
VALUES ("Test", "Test")""")
homepage
from flask import render_template
def homename(name):
# import users model
from models.users import Users
Users.raw_insert_sample()
result = Users.query.all()
res = ''
for row in result:
res = res + '<br>' + str(row.user_id)
return "<h1 style='color:blue'>Welcome %s</h1>" % res
========================================
ab test
[email protected]:~$ ab -n 200 -c 100 https://flask.dev/asdfsdfgsdfg/
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, https://www.zeustech.net/
Licensed to The Apache Software Foundation, https://www.apache.org/
Benchmarking flask.dev (be patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests
Server Software: nginx/1.4.6
Server Hostname: flask.dev
Server Port: 80
Document Path: /asdfsdfgsdfg/
Document Length: 233 bytes
Concurrency Level: 100
Time taken for tests: 0.158 seconds
Complete requests: 200
Failed requests: 0
Non-2xx responses: 200
Total transferred: 78200 bytes
HTML transferred: 46600 bytes
Requests per second: 1263.46 [#/sec] (mean)
Time per request: 79.147 [ms] (mean)
Time per request: 0.791 [ms] (mean, across all concurrent requests)
Transfer rate: 482.44 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 8 7.8 11 18
Processing: 11 56 14.7 54 86
Waiting: 7 56 14.9 54 86
Total: 22 64 16.9 57 105
Percentage of the requests served within a certain time (ms)
50% 57
66% 65
75% 74
80% 80
90% 93
95% 98
98% 103
99% 104
100% 105 (longest request)
[email protected]:~$