3

I was reading SQL Server Internals and Troubleshooting (Wrox) and it effectively says that Shared Memory is the default connection method, followed by TCP and then Named Pipes. What's curious though is that they say:

"Named Pipes was developed for local area networks (LANs) but it can be inefficient across slower networks such as wide area networks (WANs)"

I thought named pipes was strictly for IPC? And that in order to jump from IPC to network communication you had to use TCP/UDP. More interesting to me though is the mention of shared memory/memory mapped files - are they faster than NamedPipes/IPC?

sircodesalot
  • 11,231
  • 8
  • 50
  • 83
  • 3
    IPC as a concept is not restricted to a single machine, so I'm not understanding "I thought named pipes was strictly for IPC" – Damien_The_Unbeliever Apr 02 '13 at 14:36
  • 1
    That's a good point. I guess I mean I thought that Named-Pipes was strictly for communication across different processes / app domains on the same machine. – sircodesalot Apr 02 '13 at 14:38

1 Answers1

4

The answer is, as usual, "It depends." If there is a lot of data involved, shared memory will cut out much of the overhead of copying it. But using a mapped file in this way still requires some adjunct form of IPC to coordinate access to the shared memory space.

Kaelin Colclasure
  • 3,925
  • 1
  • 26
  • 36
  • Oh I see, so essentially you still need a pipe to coordinate how the memory mapped file is used, and in some cases it's just faster to use the pipe by itself? Interesting. I guess in my situation memory mapped files make sense then. – sircodesalot Apr 02 '13 at 14:43
  • Just to confirm / deny my suspicions. Are pipes strictly for IPC on the same machine, or can they also be used over the network? – sircodesalot Apr 02 '13 at 14:45
  • 4
    No, you don't need a pipe to coordinate. You can reserve an area of the MMF for flags and other control data. You have to be careful about synchronising of course. You can use a ManualResetEvent or other signalling event to synchronize too. (Pipes can be used over the network) – Matthew Watson Apr 02 '13 at 14:45
  • Yes, that's essentially correct; although there are other mechanisms than pipes that can potentially be used for coordination. For example, System V message queues, or Mach IPC ports. – Kaelin Colclasure Apr 02 '13 at 14:47