I'm trying to set data to Redis Cluster in this code: (I'm using this https://github.com/sewenew/redis-plus-plus#redis-cluster)
QByteArray request = m_client.readAll();
qDebug() << "get data from" << bk[static_cast<int>(id) - 1];
QString mess = QTextCodec::codecForMib(106)->toUnicode(request);
// messss.fromUtf8(request);
QStringList l_mess = mess.split("|");
QRegularExpression key("\"key\": \"(.*?)\"");
QRegularExpressionMatch m_key;
qDebug() << "Count " << l_mess.count();
for (int i = 0; i < l_mess.count(); i++)
{
m_key = key.match(l_mess[i]);
cluster1->set(m_key.captured(1).toStdString(), l_mess[i].toStdString());
cluster1->rpush("fonbet", "i"/*m_key.captured(1).toStdString()*/);
}
And when l_mess.count() just over 100 or 200, delay time in "for" loop is over 20 seconds!!
I tried to set a static key-value, but the delay is the same. What am I doing wrong?
You are sending 200-400 commands, you are seeing 200-400 ms per command, most of that time is network latency, RTT (Round Trip Time).
To improve your performance, use a pipeline to reduce RTT.
Be sure to check the section on Pipeline and Transaction of redis-plus-plus when it comes to Cluster.