[Implemented based on the epoll built-in leader-follower server, up to 0.5 million echo QPS (new support for LUA)]-C/C ++-chinaunix.net-

Source: Internet
Author: User

[Implemented based on the epoll built-in leader-follower server, up to 0.5 million echo QPS (new support for LUA)]-C/C ++-chinaunix.net-

[Others] [implemented based on the epoll built-in leader-follower server, up to 0.5 million echo QPS (brand new support for LUA)] [Copy link] 0 0

Linux_c_py_php

Linux_c_py_php Offline

Space points
0
Credit points
498
UID
27208017
Read Permission
90
Points
21852
Post
2196
Excellent
1
Available points
21854
Expert points
0
Online time
978 hours
Registration Time
2012-07-28
Last login
2013-03-26
 

Great fortune

Great fortune, 21852 points, 18148 points needed from the next level
Post
2196
Topic
21
Excellent
1
Available points
21854
Expert points
0
Online time
978 hours
Registration Time
2012-07-28
Last login
2013-03-26
    • Webshell
    • Friend
    • Blog
    • Message
Forum badges:
0

Direct elevator

1Building [Add to Favorites (0)] [Report] Posted on 00:02:23 |View the author only|Reverse browsing

This post was last edited by linux_c_py_php

ProgramUnder the guidance of many friends and friends in the forum, the company's kernel Department eventually achieved 0.5 million QPS for persistent connections and 70 thousand QPS for short connections, the CPU of the test machine is 12 cores, 64 MB memory, and the test environment is a standalone lo network port.

Based on the epolloneshot option of epoll, the program fully utilizes the epoll thread security feature and maximizes the connection establishment rate through an independent listening thread, the program structure of leader-follower is implemented through the thread pool and epoll, which is applicable to various business logics.

In the process of program optimization, there are two major bottlenecks:

1. epoll thread security. Therefore, internal locks may cause bottlenecks for multi-threaded epoll FD sharing. By creating multiple groups of epoll FD, the bottleneck can be resolved by reducing the competition for locks and making full use of hardware performance.
2. The short connection setup capability is poor. Without Optimization of network parameters, the capability can only be set up at 30 thousand/second. After parameter optimization, the capability can be set up at 80 thousand/second. For details, referCodeReadme.

The Code is as follows. The first 255 lines of small code have obvious bottlenecks:(0.15 million QPS)
Server.tar.gz (1.85 kb, downloads: 89) Upload

Downloads: 89
One server. c

The code after solving the above two problems can support 0.5 million QPS:
Lfepoll.tar.gz (2.69 kb, downloads: 106) Upload at a.m. on February 19

Downloads: 106
It's really efficient.

This is the code that introduced Lua and does not support yield, because it is too difficult to change the code to a state machine, and the program itself is leader-follower, therefore, it is not necessary to provide some practical interfaces such as Asynchronous CONNECT:
Lfepoll.tar.gz (4.27 kb, downloads: 33) Upload

Downloads: 33
Supports Lua (an error has just been reported !)

Test the Lua version performance and find that the lual_loadstring frequently calls a serious loss of performance. Therefore, the lual_loadstring is loaded only once and a reference is kept in the Registry for reuse, now the program bottleneck has been transferred to lua_pcall, and it cannot be optimized by visual testing. (modify logic before testing. change Lua to the pure echo service. Otherwise, the test stress tool may not work properly)

Lfepoll.tar.gz (4.38 kb, downloads: 36) Upload

Downloads: 36
Optimize lual_loadstring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.