PostgreSQL UNIX domain sockets vs TCP sockets

前端 未结 5 779
野性不改
野性不改 2020-12-07 11:19

I wonder if the UNIX domain socket connections with postgresql are faster then tcp connections from localhost in high concurrency rate and if it does, by how much?

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 11:46

    I believe that UNIX domain sockets in theory give better throughput than TCP sockets on the loopback interface, but in practice the difference is probably negligible.

    Data carried over UNIX domain sockets don't have to go up and down through the IP stack layers.

    re: Alexander's answer. AFAIK you shouldn't get any more than one context switch or data copy in each direction (i.e. for each read() or write()), hence why I believe the difference will be negligble. The IP stack doesn't need to copy the packet as it moves between layers, but it does have to manipulate internal data structures to add and remove higher-layer packet headers.

提交回复
热议问题