Re: [asio-users] How to share an UDP socket for a high performance server
Brought to you by:
chris_kohlhoff
From: Gheorghe M. <ghe...@gm...> - 2012-08-29 20:03:16
|
I can do and want to do concurrent processing for multiple clients at the same time. My only reservation was if I can call methods for sending or receiving async on the same socket. I guess that I can make my server scalable by calling ioservice run from multiple threads. I'll have to look over that. I find it quite strange I couldn't find anything on udp sockets documentation about possibly using same socket for concurrent writes/reads to different clients. Using it like that could bring me in very subtle bugs on high load and don't want to go on that road without making sure of that first. On Aug 29, 2012 10:52 PM, "Christof Meerwald" <cm...@cm...> wrote: > On Wed, 29 Aug 2012 22:23:04 +0300, Gheorghe Marinca wrote: > > Thanks for prompt replay Jeff, you are right. > > But in cases where I have a high performance server the steps 4 ->5 are > > interleaved with the server starting receiving other datagrams from > other > > clients *while* I do things that take time to process the clients > requests. > > And in this case I end very easily in the case where I have to "share" > that > > socket (keep in mind that I use async version for reading and also > writing > > to it so it becomes even more difficult to reason when I can use that > > socket considering multiple clients. > > For a datagram socket it's perfectly fine to have multiple threads > calling send concurrently for the same socket (as each send operation > is atomic and the operating system will take care of that). Having > said that, boost asio might use additional synchronisation for its > internal data structures which could introduce lock contention and > negatively affect performance. > > BTW, for datagram sockets you can even call recv concurrently from > multiple threads - and in fact, if your main concern is performance, > the best option could be to have multiple threads use a blocking recv > on that socket. Of course, it depends on the protocol and processing > you need to do if you can use this approach. > > > Christof > > -- > > http://cmeerw.org sip:cmeerw at cmeerw.org > mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > asio-users mailing list > asi...@li... > https://lists.sourceforge.net/lists/listinfo/asio-users > _______________________________________________ > Using Asio? List your project at > http://think-async.com/Asio/WhoIsUsingAsio > |