Take the 2-minute tour ×

I've got some programs that occasionally (anywhere from every few minutes to once an hour) need to send metrics to Graphite. Should I keep the socket to the graphite server open for the duration of my process or make a new connection every time I need to send some metrics? What are the considerations when doing one or the other?

share|improve this question
What did you end up with ? –  Jigar Joshi May 24 '12 at 11:58
I haven't actually finished the implementation yet :) I'm likely going to go with just opening a new socket each time. –  Kamil Kisiel May 24 '12 at 19:46
Does it effect performance considerably? –  Jigar Joshi May 25 '12 at 4:20
add comment

1 Answer

Sounds like you need a TCP connection.

If you should keep the connection active or not depends on answers to points like: - Would you like to monitor the "connected" clients at the server at any given time? - Is there a limit at the Server side in relation to the previous point? - The amount of such clients "connected" to the server? - Is it a problem if the connection creation takes some time?

If you keep the connection open, just make sure to send keep-alive messages from time to time (application level proffered).

A large amount of clients connected to the server, even when not active, may consume resources of memory or objects (for example, if there is one thread per connection). On the other hand, keeping the connection on, will allow the client to detect if there is a connection problem to the server much faster (if that even matters).

it all depends on when is needed.

share|improve this answer
add comment

Your Answer


