[Haskell-cafe] Exceeding OS limits for simultaneous socket connections

Marc Weber marco-oweber at gmx.de
Mon Jan 30 15:00:53 CET 2012


What you can try
- reduce amount of threads running at the same time - thus accept less
  connections. AFAIK the OS has a buffer caching the connection request
  for a while - thus this may just work.

  Using STM it would be trivial to implement it: try incrementing a var,
  if it is > 100 fail. It will only be retried if the vars change or
  such, correct?

  When you're done decrease the number.

- increase limit (you said this is no option)

- replace getContents conn by something strict and close the handle
  yourself? (not sure about this.)
  Eg yesod introduces conduits for that reason =>
  http://www.yesodweb.com/blog/2011/12/conduits
  There are alternative implementations on hackage.

- not sure how many apps are running at the same time. But instead of
  creating many connections from machine A to B you could try
  establishing a permanent connection sending binary streams or "chunk"
  the messages. Eg wait for 5 requests - then bundle them and send them
  all at once (depneds on your implementation whether this could be an
  option).

That's all which comes to my mind. Probably more experienced users have
additional ideas. Thus keep waiting and reading.

Marc Weber



More information about the Haskell-Cafe mailing list