redis-cell throw error:[Cell error: cannot parse integer from empty string] high rate
cnsky2016 opened this issue · 8 comments
redis-cell can call by java api? for example jedis?
redis-cell is installed within Redis itself, and exposes itself as a new command in the program. That means you should be able to call it from any language that has a driver that can execute commands, so yes.
@brandur thanks for your answer. today i test your module,when set tokens per second high (eg. 8000/s) ,cell moudule reponse error:[Cell error: cannot parse integer from empty string],however 7000/s is ok。the error is from cell module or my test code?
test info:
os:centos6.4;
redis:4.0.6;
cell-module:master,Compile by rust 1.23.0
test code: 10 thread apply for one token at a time continuously by jedis
cmd is CL.THROTTLE user123 1 8000 1 1
Ah, you're right. That's really weird — I suspect it has something to do with doing the math around very fast rates, but I took a nominal look through the code and nothing jumped out at me. Sorry, but I'll have to spend some time doing more in-depth debugging, which I might not get to right away.
Strangely, it gets more unstable the faster you try to make the rate. At 7000/2s I saw it fail maybe only one run in five. When I bump that to 8000/2s, it fails about half the time, and when you bump it to 8000/s, it fails every time.
Here's my test script:
require "redis"
r = Redis.new(port: 8008)
num_allowed = 0
num_blocked = 0
begin
1000.times do
resp = r.call("CL.THROTTLE", "user#{Time.now.to_i}", "1", "8000", 1, 1)
if resp[0] == 0
num_allowed += 1
else
num_blocked += 1
end
end
ensure
p "Allowed: #{num_allowed}"
p "Blocked: #{num_blocked}"
end
And running Redis with:
redis-server --port 8008 --loadmodule target/release/libredis_cell.dylib
A fix by @javitonino has been released as part of 0.2.2.
jedis can't support redis-cell
@likun007 support, jedis3.x, jedis3.x support module.
Jedis client = .....
//cmd is object that implementation class of protocol command (cl.throttle )
client.getClient().sendCommand(cmd, new byte[][]{encode(key),
encode(String.valueOf(MAX_BURSR)),
encode(String.valueOf(MAX_QPS)),
encode(String.valueOf(TIME)),
encode(String.valueOf(PER))});
List ret = client.getClient().getIntegerMultiBulkReply();