Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
November 19, 2013
Chris
JavaScript, PHP
Comments Off on New GitHub repo: simple php-long-polling for creating real-time apps

New GitHub repo: simple php-long-polling for creating real-time apps

PreviousNext
php

Mornin’ !

I’ve just pushed a sweet little new project into GitHub: A very simple and totally reduced PHP long-polling demo application, called php-long-polling. No installation, just copy, edit and run (you need Apache/PHP running).

Long-polling makes near “real-time” applications possible. So, this means that whenever “data” is updated on the server, the client will INSTANTLY be updated. For the end-user it feels like “real-time”.

The technique behind this is really simple: Usually, in an “always very up-to-date” application the client ask the server for new data in intervals, let’s say once per minute. This might work, but bombs the server with requests. Just imagine you have 10.000 people on your site, everyone sending requests permanently, once per minute. That’s (averaged) 167 per second.

With long-polling, the client sends a request – and gets no direct answer. The client-server connection is kept open, the request still pending. This can take hours. When the server has “new data” suddenly, the requested script (might be a simple .php) delivers the data, the client gets the data, the connection is closed… and the whole thing starts again until there’s new data.

This offers excellent possibilities for near real-time application or passive monitoring. For basic apps, we don’t even need special tools, a simple .html, simple js. and a simple .php is everything you need.

 

The right webserver

Biggest issue! When having a lot of connection to clients open, the Apache server will create a thread (?) for every request – which results in a quite large usage of RAM. As the casual apache thread is 15 MB, this might sum up dramatically quite fast. There’s a lot of opposing opinions on that on the web, I’m still not sure what to use, some people say NGINX and lighttpd are perfect, some say node.js is the only way to go – but that’s a totally different topic. Appserver.io also seems promising.

Has anyone here experiences in scaling long-polled js/php applications ? What’s the way to go when it comes to servers ? Feel free to comment…

 

ajaxJavaScriptjqueryJSlong-pollingPHPreal-time
Share this

“Fuck you. Pay Me.” How to deal with clients, the professional way. An excellent talk with Mike Monteiro.

Excellent (and very useful) speech by Mike Monteiro about how to deal with clients, how to create a professional relation

php

Awesome list of Design Patterns with PHP code examples

Probably one of the most useful GitHub repositories ever: Dominik Liebler has published a well-reseached and well-written (PSR coding guidelines

Disappointed by Watch Dogs’s graphics ? See how it looks with unlocked, hidden settings. Awesome!

When you are interested in 3D and game graphics in general, you probably stumbled upon these excellent and extremely good-looking

composer

[Link] How to require versions of PHP, HHVM / HipHop, GD, curl, openssl etc. with Composer

Jeremy Kendall has just published a short and excellent overview on how to require versions of PHP (and explicit 64-bit

hack-php

The first micro framework written in Hack is there: hack-mvc !

It has been just a few months ago Hack has been first announced, but some awesome people have already developed

dev coding cards deck

Nice gifts for devs: Nerdy playing-cards decks

Wonderful idea: Playing cards decks for developers. No, not scrum-cards, more the classic stuff. Code:deck $10 plus $5 for shipping

Perfect HTML email templates for perfect HTML emails (outlook!) with INK

The people behind FOUNDATION, the excellent responsive frontend framework, have just released a set of highly professional, perfectly compatible HTML

phpstorm-8

When PHPStorm’s cache eats up your harddisk space

I recently stumbled over this: By default PHPStorm (obviously in all versions since 1.0) creates a local history of all

php

Somebody is writing a compiler for PHP, compiles down to machine code, outperforms HHVM

Yes, that’s right. Recki-CT compiles PHP down to machine code. It’s unbelievable what’s going on in the PHP world in

october cms

[Link] How To Install October CMS on a VPS running Ubuntu 14.04

Quick tutorial on how to install October CMS on Ubuntu 14.04 by DigitalOcean. Worth a bookmark, does the job. I

1/4

Categories

Search

times-new-roman
The Times talks about Times New Roman (3min video)
Test GZIP compression of your server easily
goodbye-lamp-going-hhvm-nosql-nginx-php
[RePost] Goodbye LAMP: Going Nginx, NoSQL, HHVM (41min conference talk with Arne Blankerts)
Microsoft announces “holographic” 3D interfaces (promo video)
vagrant
Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click
php-legacy-code
Interesting talk on modernizing a legacy PHP codebase
battlefield-3-free
Electronic Arts / Origin offers Battlefield 3 for free (limited promo action) !
java vs php
Switching from Java to PHP. Seriously. A very interesting and pre-judice-free talk with Ph.D. Aris Zakinthinos
phpstorm 7.0 php
PHPStorm 7 has been released!
composer
How to install Composer on Windows 7 / 8 or Ubuntu
mod-rewrite-ubuntu-14-04-lts
Which server OS version to choose ? Some EOL lists of Debian, Ubuntu and CentOS
sass laravel
SASSmeister is a real-time JSfiddle for SASS / CSS. Awesome!
php uk conference
Slides & talks from PHP UK Conference 2014
php
How to use the PHP 5.5 password hashing functions
MINI2, an extremely simple barebone PHP application on top of Slim

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy