E
E
esc2012-03-26 21:51:17
NoSQL
esc, 2012-03-26 21:51:17

data processing in redis

I'm learning redis.

I want to calculate the ratio of files, as the ratio of the traffic they generated to their size.

There are htraff and nsize hashes, the key is the file name, value, respectively, traffic and size. To calculate the ratio, now I use the following code:

$hsize=$redis->hGetAll("hsize");
$htraff=$redis->hGetAll("hraff");

foreach ($v as $hash=>$size)
  $redis->zAdd("hratio",$htraff[$date][$hash]/$size,$hash);


So that later you can select the top 50 most popular files. The code runs wildly slow (last line), which is not surprising.

How can this passage be rewritten more efficiently? Ideally, processing inside the database (a la update files set ratio=traff/size), or at least mass insertion of values. Or is radish not suitable for such a task?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
4
4dmonster, 2012-03-27
@4dmonster

I'm no expert, but the latest Redis has support for LUA stored procedures, maybe this will help?

Z
Zloy1, 2012-03-27
@Zloy1

I was looking for some testing of radish and other databases. I found one in which the author claimed that the muscle is an order of magnitude slower. But in the ensuing discussion, the author was presented with indisputable evidence of the incorrectness of the measurements taken. And the discussion came to the conclusion that neither muscle nor postgre are practically inferior in performance to radish.
Therefore, the only advantage of radish is ease of use. If it is necessary to include calculations on the server in the task, then here I see one solution - abandoning the radish in favor of the muscle or postgre.
read the article at the link and all the comments - it's worth it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question