R
R
Rhaps1072013-11-22 20:25:54
PHP
Rhaps107, 2013-11-22 20:25:54

Why is Redis slow to get the value of a scalar key?

Good afternoon.
I am new to Redis.
Installed the server on Centos OS, no additional. did not make settings.
I use Radish as a client ( rediska.geometria-lab.net/).
Previously saved a scalar key to the database:

$options = array(
     'servers' => array(
         'server1' => array('host' => '127.0.0.1', 'port' => 6379)
     )
);
$rediska = new Rediska($options);
$key = new Rediska_Key('keyName');

$key->setValue('value');

Then I run the script to get this value:
$options = array(
     'servers' => array(
         'server1' => array('host' => '127.0.0.1', 'port' => 6379)
     )
);
$rediska = new Rediska($options);
$key = new Rediska_Key('keyName');

$key->getValue();

The time of the script to receive is from 8 to 15 ms. In my opinion, this is a lot.
For example, connecting to a PostgreSQL database and executing a SELECT VERSION(); works about 3 times faster.
Getting data from a homemade file storage is about 10-100 times faster than Redis.
Is this the normal speed for Redis? Is it possible to speed up?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Sundukov, 2013-11-22
@alekciy

The time of the script to receive is from 8 to 15 ms.

The time it takes to request a radish has nothing to do with the time the script always runs. The total time is influenced by many factors. Considering that radish is a PHP class, it can take a lot of time to load it (apparently accelerators are not used). And the request time is more correctly measured like this:
$start_time = microtime(true);
$key->getValue();
$end_time = microtime(true);
echo $end_time-$start_time;

It takes about 0.3 ms for a request on my Dedik through a PHP extension.

E
evnuh, 2013-11-22
@evnuh

You ask about the time of receipt of the script, but it is not clear what you measure (by the way, how do you measure?)
You have already been told about the correct measurement.
Is it possible to install php extensions ? If there is, then the choice is obvious - https://github.com/nicolasff/phpredis and fuck the radish.
About persistent connection has already been answered.

B
BasilioCat, 2013-11-23
@BasilioCat

check key retrieval speed via redis-cli
replace via time

A
Alexey, 2013-11-22
@ScorpLeX

There is an option like

persistent - Persistent connection to Redis server. By default set to false

There are also other types of connection to the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question