A sample project to showcase a real world example and benchmarks for crowphp

Overview

CrowPHP Sample project

This project is to showcase an example of how a real world project might look like. It has two basic endpoints to show-case the raw performance like "hello world" and the other endpoint that needs to connect to database and fetch some data.

Requirements

  1. PHP-CLI >8.0
  2. PHP Swoole Extension
$ pecl install swoole
  1. Composer Packages
$ composer install
  1. MySQL server
  2. Import the sample schema and data from db_schema/benchmark_db.sql (the schema looks like as follows)
CREATE TABLE `Users` (
  `userId` int(11) NOT NULL,
  `firstname` varchar(45) DEFAULT NULL,
  `lastname` varchar(45) DEFAULT NULL,
  `email` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`userId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

Note: We have a single table Users inside a database named benchmark that contains around 100 rows of random data. 6. Finally, adjust your MySQL details in src/Bootstrap.php

You can run the project as follows:

php server.php
$ Crow server listening on 0.0.0.0:5005

Endpoints

  1. GET / This is a hello world example it simple returns Hello World
  2. GET /users returns a list of users from database in the following format
[{"userId":0,"name":"Rhett Purdy","email":"[email protected]"}]

Benchmarking

I have used apache benchmark Version 2.3 <$Revision: 1843412 $> to run 20k requests with 30 concurrent calls on the GET /endpoint and 100k calls on GET /users, and here are the results

  1.  ab -n 20000 -c 30 http://localhost:5005/
     This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
     Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
     Licensed to The Apache Software Foundation, http://www.apache.org/
     
     Benchmarking localhost (be patient)
     Completed 2000 requests
     Completed 4000 requests
     Completed 6000 requests
     Completed 8000 requests
     Completed 10000 requests
     Completed 12000 requests
     Completed 14000 requests
     Completed 16000 requests
     Completed 18000 requests
     Completed 20000 requests
     Finished 20000 requests
     
     
     Server Software:        CrowPHP/1
     Server Hostname:        localhost
     Server Port:            5005
     
     Document Path:          /
     Document Length:        21 bytes
     
     Concurrency Level:      30
     Time taken for tests:   1.086 seconds
     Complete requests:      20000
     Failed requests:        0
     Total transferred:      3800000 bytes
     HTML transferred:       420000 bytes
     Requests per second:    18408.63 [#/sec] (mean)
     Time per request:       1.630 [ms] (mean)
     Time per request:       0.054 [ms] (mean, across all concurrent requests)
     Transfer rate:          3415.66 [Kbytes/sec] received
     
     Connection Times (ms)
     min  mean[+/-sd] median   max
     Connect:        0    1   0.1      1       4
     Processing:     0    1   0.3      1      11
     Waiting:        0    1   0.3      1      11
     Total:          0    2   0.3      2      12
     
     Percentage of the requests served within a certain time (ms)
     50%      2
     66%      2
     75%      2
     80%      2
     90%      2
     95%      2
     98%      2
     99%      3
     100%     12 (longest request)
    This first test is trivial but, I still wanted to showcase the raw performance of the framework what this means is that the CrowPHP implementation adds almost no overhead for application.
  2. ab -n 100000 -c 30 http://localhost:5005/users
     This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
     Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
     Licensed to The Apache Software Foundation, http://www.apache.org/
     
     Benchmarking localhost (be patient)
     Completed 10000 requests
     Completed 20000 requests
     Completed 30000 requests
     Completed 40000 requests
     Completed 50000 requests
     Completed 60000 requests
     Completed 70000 requests
     Completed 80000 requests
     Completed 90000 requests
     Completed 100000 requests
     Finished 100000 requests
     
     
     Server Software:        CrowPHP/1
     Server Hostname:        localhost
     Server Port:            5005
     
     Document Path:          /users
     Document Length:        7190 bytes
     
     Concurrency Level:      30
     Time taken for tests:   24.018 seconds
     Complete requests:      100000
     Failed requests:        0
     Total transferred:      736600000 bytes
     HTML transferred:       719000000 bytes
     Requests per second:    4163.58 [#/sec] (mean)
     Time per request:       7.205 [ms] (mean)
     Time per request:       0.240 [ms] (mean, across all concurrent requests)
     Transfer rate:          29950.16 [Kbytes/sec] received
     
     Connection Times (ms)
     min  mean[+/-sd] median   max
     Connect:        0    0   0.1      0       6
     Processing:     1    7   2.5      7      45
     Waiting:        1    7   2.5      6      44
     Total:          1    7   2.5      7      45
     
     Percentage of the requests served within a certain time (ms)
     50%      7
     66%      7
     75%      8
     80%      8
     90%     10
     95%     13
     98%     15
     99%     16
     100%     45 (longest request)
    In this second result we can see that even with decent amount of data transfer the performance drop is not that much and if we look at our database the connections to the database stays steadily at 12 connections where if we were not using connection pooling we would have a lot more connections to database.

Note: System Specs

  • CPU: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz 2.30 GHz
  • RAM: 16.0 GB

Learn More

Learn more at these links:

Security

If you discover security related issues, please email [email protected] or use the issue tracker.

License

The Crow Framework is licensed under the MIT license. See License File for more information.

You might also like...
A PocketMine plugin with advanced world tools and maybe can beat MultiWorld

WorldTools A PocketMine plugin with advanced world tools and maybe can beat MultiWorld This plugin is on development! Helping me with pull request may

World Currency list in PHP constants and in array (Currency::USD)
World Currency list in PHP constants and in array (Currency::USD)

World Currency list in PHP constants and in array (Currency::USD) If you need to work with currencies in the code and describe each time "USD", "EUR"

World countries - available in multiple languages, in CSV, JSON, PHP, SQL and XML formats

Constantly updated lists of world countries and their associated alpha-2, alpha-3 and numeric country codes as defined by the ISO 3166 standard, available in CSV, JSON , PHP, SQL and XML formats, in multiple languages and with national flags included; also available are the ISO 3166-2 codes of provinces/ states associated with the countries

A PocketMine-MP plugin that can reduce or clean up the chunks in your world

AutoClearChunk A PocketMine-MP plugin that can reduce or clean up the chunks in your world Features Custom Clear Message Custom Clear Interval Time Pe

SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

We go for better world
We go for better world

Nasa-Space-Apps-Challenge-2021 We go for better world Team: Dynamo Warrior Team Member Mazharul Hasan Fozilatunnesa Mestu Paul Nayeem Hossain Belal Ud

Moodle - the world's open source learning platform

.-..-. _____ | || | /____/-.---_ .---. .---. .-.| || | .---. | | _ _ |/ _ \/ _ \/ _ || |/ __ \ * | | |

A plugin that teleports to world with Fancy Loading screen like WaterdogPE!

FancyTeleportScreen This is was made by Dyzer Development This plugin was allows you to teleport other world with LoadingScreen! Information This is w

A WordPress plugin that displays proxied war news from the free world to Russian IP address visitors with option to block further access.
A WordPress plugin that displays proxied war news from the free world to Russian IP address visitors with option to block further access.

A WordPress plugin that displays proxied war news from the free world to Russian IP address visitors with option to block further access.

Owner
Crow PHP
Crow PHP
Magento sample data includes a sample store, complete with more than 250 products

Magento sample data includes a sample store, complete with more than 250 products (about 200 of them are configurable products), categories, promotional price rules, CMS pages, banners, and so on. Sample data uses the Luma theme on the storefront.

Magento 203 Dec 16, 2022
A plugin to make life easier for users who need to edit specific functions of a world and also create, rename and delete worlds quickly using commands or the world management menu.

A plugin to make life easier for users who need to edit specific functions of a world and also create, rename and delete worlds quickly using commands or the world management menu.

ImperaZim 0 Nov 6, 2022
A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 -> DF world conversion.

ChunkLoader A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 -> DF

null 2 Aug 10, 2022
A highly compressed version of the magento 1.9 sample data and a script to create it.

Compressed Magento 1.9 Sample Data The following variations are available: 65M compressed-magento-sample-data-1.9.2.4.tgz 64M compressed-magento-sampl

Vinai Kopp 120 Sep 9, 2022
Sample application to bookmark links, where interface build with Angular.js + Twitter Bootstrap and server powered by PHP with Slim Framework

RESTful Bookmarks PHP Slim TODO: review and update FrontEnd Sample application to bookmark links, where interface build with Angular.js + Twitter Boot

Erko Bridee 50 Dec 15, 2021
Sample Web Application in Laravel with tailwind css

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Mulindwa Denis 1 Nov 26, 2021
Sample code for several design patterns in PHP 8

DesignPatternsPHP Read the Docs of DesignPatternsPHP or Download as PDF/Epub This is a collection of known design patterns and some sample codes on ho

null 21k Jan 5, 2023
Invo - Sample application for the Phalcon PHP Framework

INVO Application Phalcon is a web framework delivered as a C extension providing high performance and lower resource consumption. This is a sample app

The Phalcon PHP Framework 344 Dec 14, 2022
Album-o-rama - Sample application for the Phalcon PHP Framework.

Album O'Rama Phalcon PHP is a web framework delivered as a C extension providing high performance and lower resource consumption. This is a sample app

The Phalcon PHP Framework 84 Oct 7, 2022
Polonium is a world class old school ✍️ blog website made with Php and Tailwind 🌀

Polonium Polonium is a world class old school ✍️ blog website made with Php and Tailwind ?? to write dump articles about... Yeah I know, you should pr

Youness Idbakkasse 2 Jan 10, 2022