Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 4 - Pages: 1  
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

Wireless: An idea on hiding network latency

At 12:18 PM on Feb 25, 2005, Denis Baranov wrote:

It's become really easy to program network data exchange between a wireless client and a server. Client will compose a long string (really long string) consisting of URL and another one, under the covers, the body of HTTP request, with headers and stuff. When done, it will begin transmitting it. And it will not expect anything in response until it's done sending. A servlet on the server side will read all the data from the request, decompose this data into transactions (this is the least of optimizations that is expected of a client, to combine several messages in one request). Then, the server will process all messages, combine all results in a payload (usually, a StringBuffer (*)), and return it all together in response.

Seeing anything wrong with that approach? While current wireless networks boast great bandwidth, making a connection and having the first bytes of transmission appear on the other end of the wire takes a sizable time to see. Which causes even smallest of transactions to appear intolerably slow.

It is possible to make this less painful to the user:
- the client must expect response from the server the very moment it estabilished connection;
- reading must be performed in parallel with writing;
- server and client must agree on the fact that every session of data exchange is not atomic, every session must be divided in smaller bites;
- it also holds true that the server must send the piece of information in response to every such bite-sized transaction as soon as it's done, should not wait till all transactions in request are processed.

Benefits
- network latency is reduced;
- application liveliness and user-frendliness is improved;
- less memory is needed on client and the server to complete exchange, as results are not buffered explicitly by applications on either side.

Complications:
- can not use IWeb interface in BREW, must program sockets (**); (J2ME is so much better in this regard, got a connection - have a DataInput/OutputStream);
- must program multiple threads (BREW programmers will find themselves at a disadvantage here);
- object-oriented approach on the server gets non-trivial, as operations have to be performed on-the-wire, meaning server has to operate on input and output streams and not on collection of transactions;
- substantial changes to the protocol of an existing system will be required, as both client and server must redefine result as sequence of successes and failures of small transactions and not a single result of all transactions
- as server processing gets potentially longer, special care has to be taken to prevent long-running transaction from occurring (***).

Overall, it may be impossible to convert an existing system built around simplistic approach. This prposed approach should be adopted before programming begins, during design phase.


(*) Ways to abuse StringBuffer exist and are not uncommon. Frequently, response to a particular message is constructed using StringBuffer, but the method itself would do a toString() which negates the benefit of using StringBuffer within the method body.

(**) A good third-party library may reduce the pain, but has to be purchased or licensed.

(***) E.g. if database is being accessed, connection must be obtained for every small transaction and released immeediately afterwards.
1 . At 9:41 AM on Feb 27, 2005, Tony Weston wrote:
  Click to reply to this thread Reply

Re: Wireless: An idea on hiding network latency

Excellent Idea, and one that I employed when developing iMessage400. By pipelining many transactions into one send, and not waiting for the response, I get amazing performance.

Take a look here: http://imessage400.homeip.net/index.html (check out the webstart demo). I am using pure sockets to do this rather than HTTP.

Also, There is one major problem..... 'Get's' are defiantly out, as with 'get', the computer must wait for the response to each 'get' request..... Imagine a screen with lots of individual combo boxes, each requiring a 'get' to populate the data. This would be very slow, as the communications layer could not pipeline the many requests to the server, and would have to pass back each response to the 'get' before knowing what request to send next.

Cheers,
Tony.
2 . At 12:23 PM on Feb 27, 2005, Denis Baranov wrote:
  Click to reply to this thread Reply

Re: Wireless: An idea on hiding network latency

Great to know this approach has been used, and with success, and not only in Wireless field :)

One note with regards to "GET" requests. What you mention is valid, but only if the client is a browser. Otherwise, there is little difference between GET and POST. Programmatically, both kinds of HTTP requests allow to access the Input/OutputStream. The issue of "indivisibility" of a form data is a more serious one... If data can not be divided in smaller transactions, there is little way to take advantage of pipelining.
sometimes, I write something in here
3 . At 3:25 PM on Feb 27, 2005, Tony Weston wrote:
  Click to reply to this thread Reply

Re: Wireless: An idea on hiding network latency

Hi again,

I think I probably didn't explain myself properly. The 'Get' I was refering to was the 'get' as in getters, and settters (Used in MVC) rather than 'get' as in 'get' type http requests from the server. The point been I would like to make, is if the application has been 'properly' split using MVC, and the View queries the Model for data, then this will be done with a series of 'Gets' to the model object,. The object Might need to query the server (using a http request) to get this data.


View Model Server.

The view might need several different sets of data to build the screen, and is using a 'get' type method to retrieve from the model, ie the following code could be in the View layer, and used to populate, for example,combo boxes.
Vector x= mdl.getCustomerCodes();
Vector y= mdl.getProductCodes();
Vector z= mdl.getCurrencies();

The model might need to query the server 3 times for the customer/product and currency codes. However, because the model has to actually get the customer code response and pass this back to the view BEFORE the view asks the model for the product codes, it is impossible for the model to use the techniques you describe to pipeline many requests into one http request. This, IMO, is a fundamental flaw in using 'Get' (and one of the reasons MVC apps tend to be so slow).

A better way is to separate the requesting and receiving of data at the view layer. and use a queueing mechanism to pass a set of requests to the model layer, who then can intelligently view the multiple queued requests, and by using your idea build a single http request from this.

Cheers,

Tony.
4 . At 1:47 PM on Feb 28, 2005, Denis Baranov wrote:
  Click to reply to this thread Reply

Re: Wireless: An idea on hiding network latency

Ah, I see. Certainly a valid concern. Hope it can be relieved by the fact that Model, fortunately, abstracts the initailization/loading of its internal data. So, one could have all values for all comboboxes loaded the very moment Model is instantiated, or load lazily, but still in bulk.
sometimes, I write something in here

thread.rss_message