0

I've written a simple web sevice where an handheld device connects to a Twisted script on a server. The device sends data to the script, the script uses this data to query a MySQL db, the db content is sent back to the device. The script is based on the script written in this tutorial

http://www.raywenderlich.com/3932/networking-tutorial-for-ios-how-to-create-a-socket-based-iphone-app-and-server

how would a script like this handle a large amount of connections? in my head, its only limited by the server, the higher the server memory the higher the amount of connections you can handle. But will the script perform well with large amounts of connections? For every connectiong a new instance of the connection is made, and a new instance of the db is made for that connection when there is a query, so its all handled asynchronously i believe, so is the only performance limit the servers cpu power and memory? coping with high connection volumes is done by expanding your servers? for my service, a connection may remain open from anywhere between 1 - 3 hours, so its possible that the server memory will fill and crash the server.

also, does anybody know what the size of a connection instance would be?

probably more of a servers question than a Twisted question! but Thanks very much for reading!

ThriceGood
  • 1,633
  • 3
  • 25
  • 43
  • I imagine this is more of a kernel/tcp-ip-stack issue as you say - I doubt Twisted imposes any specific limits of it's own. Read http://stackoverflow.com/q/2332741/66349 and I would suggest considering redesigning your architecture. Perhaps UDP would be more appropriate? – Peter Gibson Sep 11 '14 at 09:35
  • Switching to UDP without specific good reasons to do so is a common newbie mistake. Be ware! – Jean-Paul Calderone Sep 11 '14 at 12:14

1 Answers1

2

You should perform stress tests. You should generate a large amount of connections and see how performance drops. You might have no problem, but if you do, you should optimize the code which handles the connections, normalize your database and index your database fields. But there is no need for premature optimizations.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • 1
    Great answer. Testing is the only general way to know for sure. – Jean-Paul Calderone Sep 11 '14 at 12:13
  • so far im feeling that the script can handle infinite connections once there is infinite cpu and memory. but i was also thinking that this script is listening to one port. this would cause big performance issues with large amounts of connections. Is there any way around this bottle neck? – ThriceGood Sep 11 '14 at 13:07