Home  >  Article  >  Backend Development  >  What is the difference in performance between LUA and PHP in WEB applications?

What is the difference in performance between LUA and PHP in WEB applications?

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-05-18 17:54:361630browse

This article will introduce to you the performance differences between LUA and PHP in WEB applications. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

What is the difference in performance between LUA and PHP in WEB applications?

Analyzing the performance comparison of LUA and PHP in WEB applications is what this article will introduce. The LUA framework used in WEB development in the past few days has been completed, and the framework has included a database. The operation and template operation functions can be easily and conveniently applied to WEB development. At this time, I conducted full stress tests on the LUA framework and the WEB application developed by PHP respectively

Server configuration: one WEB server, one stress test server, both dual-core 4G memory, CentOS 64-bit operation System

Network environment: LAN

Software environment: yo2lua (50 threads), Nginx PHP-FPM (50 processes)

The applications are all connected to the MySQL database to query 1 row Data and output (there is only one row of data in the table)

Stress test software: httperf autobench

Operation command line:

autobench
--host1=192.168.200.251
--port1=8001
--host2=v2.54xing.com
--port2=80
--uri1=/
--uri2=/a.php
--quiet
--low_rate=500
--high_rate=5000
--rate_step=100
--num_call=1
--num_conn=10000
--timeout=10
--file /tmp/result.tsv

Start from 500 concurrency until 5000 concurrency, Each test is based on 10,000 connections to obtain the average value, as shown in the figure:

What is the difference in performance between LUA and PHP in WEB applications?

From the analysis of the test results, PHP performance deteriorates when the number of concurrency reaches 800 Severe decline and instability. LUA, on the other hand, experienced a sudden performance drop when it reached 3,200 concurrencies. When it reached 3,800 concurrencies, its performance dropped by half and became unstable, but it could still maintain above 2,000 concurrencies.

This simple test tells me that the performance of LUA in WEB applications can be more than 4 times that of PHP, and when LUA has 3,000 concurrencies, it takes up very little server resources, which is much lower than PHP. many.

The WEB development framework of LUA is positioned to be simple and high-performance. Maybe some complex functions cannot be realized. I think these functions can be developed in PHP-like languages. There is no need to use this development framework. It has become complicated and huge, otherwise it will deviate from the original simple and efficient purpose

The seamless connection between LUA and C has completely conquered me_-!! ~ I just used a quad-core 8G memory WEB server Run a stress test and achieve a stable concurrency of 4500 concurrency/second.

The above is the detailed content of What is the difference in performance between LUA and PHP in WEB applications?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete