如何设计用于数据查询和数据更新的系统

时间:2022-05-29 17:08:37

The target is simple: clients post http requests to query data and update record by some keys。 Highest request: 500/sec (the higher the better, but the best is to fulfil this requirement while making the system easy to achieve and using less mashines)

目标很简单:客户发布http请求以查询数据并通过某些键更新记录。最高请求:500 /秒(越高越好,但最好是满足此要求,同时使系统易于实现和使用更少的mashines )

what I've done: nginx + php-cgi(using php) to serve http request, the php use thrift RPC to retrieve data from a DB proxy which is only used to query and update DB(mysql). The DB proxy uses mysql connection pool and thrift's TNonblockingServer. (In my country, there are 2 ISP, DB Proxy will be deployed in multi-isp machine and so is the db, web servers can be deployed on single-isp mashine according to the experience)

我做了什么:nginx + php-cgi(使用php)来提供http请求,php使用thrift RPC从数据库代理中检索数据,该代理仅用于查询和更新DB(mysql)。 DB代理使用mysql连接池和thrift的TNonblockingServer。 (在我的国家,有2个ISP,DB Proxy将部署在多个isp机器上,因此是db,web服务器可以根据经验部署在单个isp mashine上)

what trouble me: when I do stress test(when >500/sec), I found " TSocket: Could not connect to 172.19.122.32:9090 (Connection refused [111]" from php log. I think it may be caused by the port's running out(may be incorrect conclusion). So I design to use thrift connection bool to reduce thrift connection. But there is no connection pool in php (there seem to be some DB connection pool tech) and php does not support the feature.

什么麻烦我:当我做压力测试(当> 500 /秒)时,我发现“TSocket:无法连接到172.19.122.32:9090(连接拒绝[111]”从php日志。我认为它可能是由于端口耗尽(可能是不正确的结论)。所以我设计使用thrift连接bool来减少thrift连接。但是php中没有连接池(似乎有一些数据库连接池技术)并且php不支持该功能。

So I think maybe the project is designed in the wrong way from the beginning(like use php ,thrift). Is there a good way to solve this based on what i've done? And I think most people will doubt my awkward scheme. Well, your new scheme will help a lot

所以我想也许这个项目从一开始就是以错误的方式设计的(比如使用php,thrift)。基于我所做的事情,有没有一种好方法可以解决这个问题?我想大多数人会怀疑我的尴尬计划。那么,你的新计划将会有很大帮助

thanks.

1 个解决方案

#1


0  

"TSocket: Could not connect to 172.19.122.32:9090 (Connection refused [111])" from php log shows the ports running out because of too many short connections in a short time. So I config the tcp TIME_WAIT status to recycle port in time using: sysctl -w net.ipv4.tcp_timestamps=1 sysctl -w net.ipv4.tcp_tw_recycle=1

“TSocket:无法连接到172.19.122.32:9090(连接被拒绝[111])”从php日志显示由于短时间内连接过多而导致端口耗尽。所以我使用以下命令将tcp TIME_WAIT状态配置为及时回收端口:sysctl -w net.ipv4.tcp_timestamps = 1 sysctl -w net.ipv4.tcp_tw_recycle = 1

it works! what droubles me is sloved, but to change the kernal parameter will affect the NAT. It's not a perfect solution. I think a new good design of this system can be continue to discuss.

有用!令我烦恼的是解决了,但改变核心参数会影响NAT。这不是一个完美的解决方案。我认为这个系统的新设计可以继续讨论。

#1


0  

"TSocket: Could not connect to 172.19.122.32:9090 (Connection refused [111])" from php log shows the ports running out because of too many short connections in a short time. So I config the tcp TIME_WAIT status to recycle port in time using: sysctl -w net.ipv4.tcp_timestamps=1 sysctl -w net.ipv4.tcp_tw_recycle=1

“TSocket:无法连接到172.19.122.32:9090(连接被拒绝[111])”从php日志显示由于短时间内连接过多而导致端口耗尽。所以我使用以下命令将tcp TIME_WAIT状态配置为及时回收端口:sysctl -w net.ipv4.tcp_timestamps = 1 sysctl -w net.ipv4.tcp_tw_recycle = 1

it works! what droubles me is sloved, but to change the kernal parameter will affect the NAT. It's not a perfect solution. I think a new good design of this system can be continue to discuss.

有用!令我烦恼的是解决了,但改变核心参数会影响NAT。这不是一个完美的解决方案。我认为这个系统的新设计可以继续讨论。