我的环境是本地机器:ubuntu 12.04 ArangoDB 2.2.4 or 2.2.3 perl driver(ArangoDB) CPU: 3 core 6 threads mem: 3GB
我使用了保存方法。保存方法等于 HTTP_GET 和 HTTP_POST。执行结果如下:
- 一个 perl 进程,插入 30000 个文档。平均 700 个请求/秒。350 HTTP_GET 和 350 HTTP_POST。
- 10个perl进程,插入30000个文档。平均 1000 个请求/秒。500 HTTP_GET 和 500 HTTP_POST。
运行 30 秒后,它会报告 HTTP 500 错误。我修改了 perl 驱动程序(ArangeDB)代码以重试它。所以我可以完成这个测试。
当 arangodb 报告 HTTP 500 错误时,它的日志如下。
2014-10-04T14:46:47Z [26642] DEBUG [./lib/GeneralServer/GeneralServerDispatcher.h:403] shutdownHandler called, but no handler is known for task
2014-10-04T14:46:47Z [26642] DEBUG [./lib/GeneralServer/GeneralServerDispatcher.h:403] shutdownHandler called, but no handler is known for task
我希望我的程序可以执行平均 3000-5000 个请求/秒并减少 HTTP 500 错误。我可以使用哪些改进。谢谢!
2014 年 7 月 10 日更新,我的插入示例脚本如下。我用 AQL 替换了保存方法。一个 perl 进程,插入 10000 个文档,平均 900 个请求/秒,1000 个 HTTP_POST/秒。(无 HTTP 500)一个 perl 进程,插入 30000 个文档,平均 700 个请求/秒,700 个 HTTP_POST/秒。(会发出HTTP 500,需要重试)
#!/usr/bin/perl
use warnings;
use strict;
use ArangoDB;
my $itdb = ArangoDB->new(
{
host => '10.211.55.2',
port => 8529,
keep_alive => 1,
}
);
# Find or create collection
$itdb->create('Node_temp',{isVolatile => JSON::true});
ImpNodes();
sub ImpNodes{
for(1..30000){
my $sth = $itdb->query('INSERT {
"id": "Jony",
"value": "File",
"popup": "public",
"version": "101",
"machine": "10.20.18.193",
"text": {
"Address": ["center","bold","250","100"]
},
"menuitem":[
{
"value": "New",
"onclick": "CreateNewDoc",
"action": "CreateNewDoc"
}
,
{
"value": "Open",
"onclick": "OpenNewDoc",
"action": "OpenNewDoc"
},
{
"value": "Close",
"onclick": "CloseDoc",
"action": "CloseDoc"
},
{
"value": "Save",
"onclick": "SaveDoc",
"action": "SaveDoc"
}]
} in Node_temp');
my $cursor = $sth->execute({
do_count => 1,
batch_size => 10,
});
}
}
我已经修改了 Arangodb-0.08 以便在 Connection.pm 中顺利插入。http_post 方法:
$retries = 100 #for testing
for(1..$retries){
( undef, $code, $msg, undef, $body ) = $self->{_http_agent}->request(
%{ $self->{_req_args} },
method => 'POST',
path_query => $path,
headers => $headers,
content => $data,
);
last if ( $code < 500 || $code >= 600 );
print "The return code is 5xx,retry http_post!\n";
print $code, " : " , $msg , " : " , $body;
select(undef, undef, undef, 3);
}