client-->gateway 1-n -->business 1-n
是不是每個business啟動時 主動找到所有的gateway 并建立一個tcp長連接。
而gateway接到請求數據后,會找一個空閑的business處理,而當business忙時,不在接受請求。
相當于gateway是異步非阻塞的, 兒business是同步的
gateway將請求轉發(fā)給一個隨機的空閑 businessWorker 來處理:
$this->router = array("\\GatewayWorker\\Gateway", 'routerBind');
$worker_connection = call_user_func($this->router, $this->_workerConnections, $connection, $cmd, $body);
public static function routerBind($worker_connections, $client_connection, $cmd, $buffer)
{
if (!isset($client_connection->businessworker_address) || !isset($worker_connections)) {
$client_connection->businessworker_address = array_rand($worker_connections);
}
return $worker_connections;
}
gateway如果connect到bussiness時,完成三次握手后,進入了accept隊列,但是這時候bussiness被平滑重啟了,會不會丟掉這次請求數據啊