AJAX / PHP Why is HTTP polling so laggy?

Why is HTTP polling so laggy?

I have a button, and whenever the user clicks it, the MySQL database field is updated and the value is displayed to the user. I do a poll every 800 milliseconds and it is very lag / buggy. Sometimes when a button is pressed, it is not registered. And I really have to be polling quite often than every 800 milliseconds.

It is also with one user on the site at the same time ... When in the end there will be a lot at once.

+3
source share
5 answers

HTTP-streaming / Long-polling / Websockets instead of polling

, (). , . , " ", " ".

- /HTTP- -. , , " ", . , , .

, , PHP (). :

:

:

, " " , , , - pusherapp ( API), . , pusherapp "Bootstrap" 100 200 000 19 ( beaconpush = > :)). SSL, . , (VPS) ( -), , , , .


, MySQL ,

- (MySQL ) . , , redis ( ) memcached ( ), . redis , . http://redistogo.com/ 5 , , , . - 5 , , , , VPS , , .


( ) - host.io/redis , VPS (). , redistogo, . - beaconpush/pusherapp - ( ). socket.io(, ) , , , , beaconpush/pusherapp.

+2

/Glitchy? . . JavaScript.

, 0,8 . , , , . ( , .) ?

, @Vern , . HTTP HTTP-, , - , . (AFAIK) , AJAX, . "COMET", , .

+1

, , . , , , .

, - ping- , .

-, , . , , . , , . , RTT (Round-Trip-Time) .

, . !

0

, Firebug Mozilla Firefox, .

Firebug , , , .

0

@Vern , , , - , MySQL, . .

By caching, I mean that php writes to a file on the server side, and then clients will simply view the contents of this single file to see the latest information. There may be better caching methods, but being the one that I have never done before, this is the first solution that popped into my head.

0
source

All Articles