Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

高并发请求下,日志出现冲突 #263

Open
winner7776 opened this issue Feb 19, 2019 · 10 comments
Open

高并发请求下,日志出现冲突 #263

winner7776 opened this issue Feb 19, 2019 · 10 comments

Comments

@winner7776
Copy link

并发请求下,日志出现被截断的情况,请问是配置问题吗?

@Neeke
Copy link
Member

Neeke commented Feb 23, 2019

能提供一个样例吗?

@winner7776
Copy link
Author

SeasLog :: warning("client_log=" . $param);
将客户端的所有请求内容写入文件中。
文件中出现类似如下的日志
warning | 32609 | 1547597038.864 | 2019-01-16 08:03:58 | client_log={"type":"Analysis","device":"8bf9c7b6a294a16e1adc0331adf381a7","channel":"100000","args":["RoleInputNtfTimeSpace","{"zoneId":"15","uid":"6488584848960188430","fightUid":"10736207526360343","timeSpaces":"92,150,99,144,97,143,104,138,115,146,94,162,96,164,93,154,94,155,89,153,103,140,97,177,81,145,96,162,97,149,104,149,98,146,95,149,94,168,92,144,102,155,97,163,94,145,97,145,97,176,97,145,97,145,96,162,97,145,96,162,112,141,84,146,104,173,92,132,121,136,99,148,106,146,97,162,95,129,97,177,97,144,113,102,140,97,160,97,129,115,159,114,123,82,175,102,139,88,165,99,129,107,181,92,148,94,161,81,162,96,146,120,154,129,97,119,129,106,145,113,146,97,164,94,146,103,154,97,145,101,157,80,149,92,168,90,109,134,112,154,107,143,97,144,98,162,112,129,98,148,112,142,113,140,114,134,111,136,106,145,97,161,80,162,116,142,103,141,96,146,97,161,96,160,81,160,97,145,108,132,104,156,95,162,87,155,100,145,94,162,97,145,98,162,95,146,112,137,105,162,97,160,97,130,95,162,96,146,99,159,102,140,98,161,96,173,83,145,96,114,147,93,163,98,164,96,138,104,143,92,160,104,144,115,144,97,145,96,161,97,145,97,162,96,150,92,145,97,161,82,159,97,164,96,160,112,130,90,158,90,145,113,146,97,162,80,160,97,139,119,144,98,161,80,161,115,96,144,97,161,81,162,97,145,96,163,95,151,125,120,116,125,100,167,99,151,80,172,104,134,97,146,111,145,98,176,80,145,97,162,96,146,96,161,97,146,97,145,96,129,145,100,162,92,145,96,166,94,157,99,149,113,123,118,157,97,149,77,177,83,155,93,153,104,146,90,144,115,144,113,145,96,161,80,178,97,104,122,113,145,98,143,115,143,103,141,105,151,111,149,100,138,115,127,113,145,97,156,92,156,106,152,84,174,97,145,96,146,99,158,96,146,96,177,97,148,78,161,107,155,94,147,96,143,98,99,174,97,128,100,162,92,166,94,145,116,134,102,156,85,146,96,165,93,161,81,176,81,163,101,141,97,162,95,162,113,134,101,136,113,146,96,140,117,146,97,161,81,162,96,145,109,144,92,139,112,152,90,146,112,161,89,153,102,149,95,139,112,145,97,161,97,144,97,162,98,144,104,160,91,96,145,113,148,94,145,103,139,96,162,112,130,103,154,113,145,97,146,112,130,97,161,96,162,101,140,97,161,120,122,95,161,98,146,111,129,98,161,106,137,101,140,112,143,101,162,96,161,91,159,92,159,88,154,99,142,97,163,96,162,98,145,101,139,98,160,114,128,113,130,112,135,123,148,96,143,97,162,80,165,94,144,97,163,88","socketTimeSpaces":"100,142,111,142,100,144,98,144,108,142,101,163,100,150,96,147,94,157,100,148,108,138,96,169,81,149,99,163,98,141,115,147,98,146,98,144,97,162,99,144,101,154,94,165,97,141,100,143,99,164,100,143,100,145,99,159,99,143,96,166,106,133,100,151,97,163,97,143,100,145,106,152,100,147,95,165,88,142,100,171,98,138,111,102,139,97,162,100,136,101,162,126,117,90,166,103,145,91,162,90,139,99,176,101,144,95,161,85,166,88,146,124,152,123,107,110,141,103,140,113,142,96,161,101,142,101,156,98,151,89,165,90,139,102,159,97,101,142,103,159,100,145,97,146,98,165,108,134,99,149,100,151,108,142,98,144,118,142,97,144,100,163,83,162,103,147,109,139,96,143,100,162,99,150,85,163,99,147,95,144,100,163,97,156,93,145,109,144,88,165,97,141,101,164,98,137,111,139,98,162,102,155,97,141,91,163,99,143,101,156,102,140,101,162,100,146,101,145,100,109,155,88,141,119,154,103,139,100,141,101,160,101,138,101,162,100,138,102,160,101,140,101,153,104,139,102,142,99,157,92,153,100,161,100,150,98,143,94,153,96,151,102,147,98,162,81,163,97,145,112,139,101,163,79,162,116,88,158,85,163,87,163,97,142,99,165,97,146,108,141,111,130,100,163,99,150,81,warning | 32609 | 1547597038.864 | 2019-01-16 08:03:58 | client_log={"type":"Analysis","

@winner7776
Copy link
Author

日志的内容显示上一次日志未输出完,后一个日志就插入到中间。

@winner7776
Copy link
Author

@Neeke

@winner7776
Copy link
Author

ping @Neeke

@Neeke
Copy link
Member

Neeke commented Feb 28, 2019

@xuhaifeng666 在写入日志时出于性能考虑,使用的是乐观锁。
请开启buffer进行尝试,会有改善

@winner7776
Copy link
Author

seaslog.use_buffer = 1
seaslog.buffer_size= 100
buffer是有开启的
@Neeke

@hi-man
Copy link
Contributor

hi-man commented Mar 16, 2019

@xuhaifeng666 高并发写触发日志截断的 demo 代码帮给个

@winner7776
Copy link
Author

$param = file_get_contents("php://input");
$param = urldecode($param);
if(!empty($param)){
SeasLog :: warning("client_log=" . $param);
}

我的代码就是收到请求打印内容,当post数据过大时就会出现日志截断的情况。

@hi-man
Copy link
Contributor

hi-man commented Mar 19, 2019

$param = file_get_contents("php://input");
$param = urldecode($param);
if(!empty($param)){
SeasLog :: warning("client_log=" . $param);
}

我的代码就是收到请求打印内容,当post数据过大时就会出现日志截断的情况。

复现出body较大时,客户端分片传输,服务端收到多个请求,样例代码只记录第一个请求,SeasLog正常记录,后续数据被样例代码丢弃(http 400)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants