Saturday, September 24, 2011

Applet to AJAX to PHP methodology

I have an Applet, which adds lines to a database one at a time, by sending an SQL string via AJAX to a PHP script. The Applet data insertion method is as follows:

private void addItem3(String newWord) {
if(LIVE) {
if(jso != null )
try {"updateWebPage", new String[] {newWord});
catch (Exception ex) {
addItem2("jso call failed... ");

Where the parameter newWord being passed to that method might look like:

INSERT INTO mytable (Partid, OpCode, ItemLeft, ItemRight, Raw, Rate) VALUES (684, 1, 2, 5, 1, 34)

The JavaScript function updateWebPage and the PHP script were given in my previous post, so I won't repeat them here.

The thing is, even a single instance of the Applet can generate new lines very quickly, sometimes once a second. So a classroom of 25 students might generate 25 lines a second. How will my ISP server react to all these requests to open a connection, insert a single line of data, and close the connection.

In my experience, a typical eCommerce interaction involves a fairly long data reading session (browsing a catalogue) and then at the end, perhaps the insertion of a single line of data into a purchase order table. And from forum browsing, most Applet games seem to download some data at the start of the game, and then perhaps upload a line of data at the the end of the game. And if it is a game like Pacman, it might last for 10 or 15 minutes, or longer. So I am inclined to believe that your average eCommerce server, and certainly not a budget one like the one I use, is not designed to cope with such frequent data updates from a single source.

This blog is intended for theory questions and problems. Practical implementation thoughts and solutions are the domain of my Rasch blog, so I think I'll transfer this one over there.

No comments: