Pipelining ਕਈ ਰੈਡਿਸ ਕਮਾਂਡਾਂ ਨੂੰ ਇੱਕ ਸਿੰਗਲ ਨੈੱਟਵਰਕ ਰাউਂਡ-ਟ੍ਰਿਪ ਵਿੱਚ ਭੇਜਦਾ ਹੈ ਬਜਾਏ ਹਰੇਕ ਕਮਾਂਡ ਦੇ ਜਵਾਬ ਦੀ ਉਡੀਕ ਕਰਨ ਤੋਂ ਪਹਿਲਾਂ ਅਗਲੀ ਕਮਾਂਡ ਭੇਜਣ ਦੇ। ਇਹ ਬਹੁਤ ਸਾਰੀਆਂ ਕਮਾਂਡਾਂ ਜਾਰੀ ਕਰਦੇ ਸਮੇਂ ਥ੍ਰੋਪੁੱਟ ਨੂੰ ਨਾਟਕੀ ਤਰੀਕੇ ਨਾਲ ਬਿਹਤਰ ਬਣਾਉਂਦਾ ਹੈ, ਕਿਉਂਕਿ ਨੈੱਟਵਰਕ ਲੇਟੈਂਸੀ — ਰੈਡਿਸ ਆਪ ਨਹੀਂ — ਅਕਸਰ ਗਲੜਾ ਹੁੰਦੀ ਹੈ।
ਸਮੱਸਿਆ: ਰਾউਂਡ-ਟ੍ਰਿਪ ਲੇਟੈਂਸੀ
Normally each command is a request→reply round-trip:
send GET → wait for reply → send GET → wait for reply → ... (N × network latency)
→ Redis processes each command in microseconds, but each round-trip adds network
latency (e.g. 0.5ms). For 1000 commands, that's ~500ms JUST in waiting!
Pipelining: ਕਮਾਂਡਾਂ ਨੂੰ ਬੈਚ ਕਰੋ
pipeline = redis.();
( id userIds) pipeline.();
results = pipeline.();
