Re: [xSocket-develop] [discusstion] applying xSocket to implement an effective and robust file serv
Status: Inactive
Brought to you by:
grro
|
From: Gregor R. <gre...@go...> - 2008-11-17 19:06:21
|
Hi, in most cases it is better to use the multithreaded mode (multithreaded is the default mode). Running the service in a non-threaded mode is a performance optimization. However, the non-threaded mode will work only work, if the handler doesn't perform I/O operations such as file or network operations. To avoid outstanding threads while receiving file data, you could read the network data and write it to a file in a non-blocking mode. For instance see the Data Handler of the SimpleSmtpServer -> http://xsocket.svn.sourceforge.net/viewvc/xsocket/xsocket/core/trunk/src/test/java/org/xsocket/connection/SimpleSmtpServer.java To send a file a sync mode has to be used. For instance see the UploadHandler2 of the SimpleFileChannelPerformanceTest –> http://xsocket.svn.sourceforge.net/viewvc/xsocket/xsocket/core/trunk/src/test/java/org/xsocket/connection/SimpleFileChannelPerformanceTest.java With Java 1.7 you will have the option to access the file in an async mode. In this case you can use a non-blocking, async approach similar to the file upload scenario. If the server reaches the limit by serving many clients, a transport level load balancing solution will be used to spread the request over a farm of servers. For a more detailed explanation see link http://www.javaworld.com/javaworld/jw-10-2008/jw-10-load-balancing-1.html Gregor 2008/11/17 beijing welcome <wel...@gm...> > hi, > a discussion for applying xSocket to implement an effective and robust file > server. > > a TCP server stores lots of small pictures (from 1k to 5k for each size). > a client downloads pictures from server frequently, but seldom do uploading > job. > > as far as i know for xSocket, the server can use > SERVER: transferFrom a FileChannel to BlockingConnection in on > IDataHandler.onData() > CLIENT: can use transferTo a FileChannel from BlockingConnection > > the communication between client and server has two steps: > 1. client sends a query to server, server send back the pictures list which > need to download. > 2. client begins to download the pictures from server. > > if the client need to download more than 10 pictures in a seconds, then it > seems reasonable to use multi thread. > > the question is how to design in server side. > 1) if use multi thread, how to write the IDataHandler.onData()? if it's > BlockingConnection, will it block other threads for this connection? if > NonBlockingConnection, need to write to bytebuffer.duplicate()? > > 2) if many clients connect to the same server (e.g. more than 10k), the > multi thread will rise the connection number? how to minimize the load of > server? if use proxy to do load balance, any other problem? > > > > what's your opinion? > > any comments are appreciated. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > xSocket-develop mailing list > xSo...@li... > https://lists.sourceforge.net/lists/listinfo/xsocket-develop > > |