-1

I need a suggestion to create a auction site which is better in speed and performance. Basically i gathered knowledge by using setinterval and settimeout function for running countdown and i developed on that (Which is very slow on the server because of request has been sent to server each and every second)

Really what i need is once the server receive the request => response will need to be updated to all the user who is looking in the auction.

Any suggestion for this is much appreciated. Thank you.

Pradeep shyam
  • 1,274
  • 15
  • 27

5 Answers5

2

You will be interested in "server push" approach.

https://www.google.co.uk/search?q=server+to+browser+push

There are few discussions here too:

Push notification to the client browser

and

Is there some way to PUSH data from web server to browser?

Community
  • 1
  • 1
Germann Arlington
  • 3,299
  • 2
  • 15
  • 19
0

you can create an auction identifier and the client side should be checking with an AJAX call for a change, every second or how frequent you want.

like

needsUpdate(auctionId);

and in return you either get false , or the updated values

kommradHomer
  • 3,725
  • 4
  • 45
  • 66
0

Without knowing your requirements in detail, here is how I solved that problem in the past. First: Running scripts is heavy on the server. If you do that every second for each client and you have many clients, you will need a big datacentre. ;-)

Use a plaintext file instead. Let's say something like "auction2343.txt" where 2343 is some auctionid that makes sense to you.

The server doesn't need to invoke (expensive) processes to return the contents of that file.

And on the serverside, make some cronjob that runs every second to update the file when needed. Or alternatively, only update it when somebody makes a bid. Figure out what works in your situation.

In the file put something that Javascript can use to decide what to do, eg the last bid.

If Javascript finds the bid higher than the last value it had, you can do additional stuff, like starting up a real (expensive) script on the server, or simply show the client, or whatever it is you need.

Make sure that if you use HXR ("ajax") you add some timestamp to the URL for the textfile ("auction2343.txt"), so your clients don't fetch a cached version.

for example:

http://www.example.com/auction2343.txt?timestamp=[millis here]

Erwin Moller
  • 2,239
  • 11
  • 20
0

Set up a different kind of server. Don't try to get a good auction site running on making a lot of requests to a normal PHP server.

There are several better options, one of which includes nodejs ( http://nodejs.org/ )

Otherwise, try longpolling in your current application. But it will keep a lot of stress on the server.

René
  • 5,285
  • 3
  • 20
  • 37
0

Similar problem here, with a pretty good answer:

How do I implement basic "Long Polling"?

The problem is however, that apache2 is a blocking web server, which requires you to poll the server every once in a while, to get a response.

If you were to use a technology like node.js http://nodejs.org/ it would allow you to push from the server side to the client side, without having to refresh the page.

Community
  • 1
  • 1
Kao
  • 2,182
  • 2
  • 21
  • 30