Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redis is how to achieve inter-process communication?

Tags:

redis

We can simply use redis to achieve the remote communication such as:

redis.StrictRedis(host=REDIS_IP,port=PORT)

I don't know whether redis achieve the remote and local in same pattern ?

Maybe I just want to know how redis achieve network communication and inter-process communcation in different way?

If there is something wrong, please point out. Thanks

like image 931
halostack Avatar asked Jan 28 '26 04:01

halostack


1 Answers

Redis can handle classical TCP sockets, but also stream oriented unix domain sockets.

TCP sockets can be used to perform both network and local inter-process communication. Unix domain sockets can only support local inter-process communication.

Both kind of sockets are materialized by file descriptors. Redis is based on an event-loop working at the file descriptor level, so it processes TCP and unix domain sockets in the same exact way (using the standard network API). You will find most of the related source code in ae.c (event loop) and anet.c (networking).

You can use unix domain sockets to improve the performance of Redis roundtrips when client and server are hosted on the same box. It depends on your workload, but the performance benefit (in term of throughput) of unix domain sockets over TCP sockets is typically around 1.5 (i.e. you can process 50% more operations when using unix domain sockets).

like image 153
Didier Spezia Avatar answered Jan 29 '26 17:01

Didier Spezia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!