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
set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)

A super-simple pre-configured Vagrant box with HipHop, Hack and Hack code examples

Another game-changing project: Victor Berchet‘s HHVM Vagrant box is a simple Ubuntu 12.04 LTS Vagrant-box that comes with preinstalled HHVM/HipHop

MINI, an extremely simple barebone PHP application

For my daily work I often needed to setup super-simple PHP applications, just some more or less static pages plus

php

A super-simple introduction into PHP namespaces (7min video)

Once again, Jesse of JREAM totally nails it right on the head. A super-simple introduction into PHP namespaces. If you

php

PHP 5.6 announced, statically typed (!) “new” PHP announced by Facebook devs

PHP 5.6 goes alpha PHP 5.6 has been announced for a while now, and these days things get serious (code-freeze,

php

How to install PHP curl extension (in 5 seconds)

It’s a common wordpress problem: PHP’s curl extension is not installed! No need to mess around in config files etc,

Compare 250+ cloud server plans with Cloud Cost Calculator

How cool is that ? The Cloud Cost Calculator compares more than 250 cloud server plans of Amazon, Rackspace, DigitalOcean,

Experimenting with HHVM at Etsy (Link)

Extremely interesting blog post of Etsy on how they try out HHVM / HipHop: https://codeascraft.com/2015/04/06/experimenting-with-hhvm-at-etsy/

hack-php

Facebook releases HipHop (HHVM) 3.0, adds mysqli and support for Hack language

Lots of movement in the PHP world these days! After releasing Hack (a dramatically improved fork of the entire PHP

hearthbleed-ssl-bug

The SSL Heartbleed bug explained in 30 seconds

Another excellent comic by xkcd (a site that publishes dev/op/web-related comics, usually nailing things right to the head): This time

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

1/4

Categories

Search

This is an experimental advertisement
vagrant
Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click
php
How to install sqlite driver for PHP in Ubuntu & Debian
All new features of WordPress 3.9 in this 2 minute video
organizing css
Jonathan Snook – CSS is a Mess – How to organize CSS in big projects (54min video talk)
shadow dom
Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file
battlefield-3-free
Electronic Arts / Origin offers Battlefield 3 for free (limited promo action) !
This picture shows the icon of blindness
How blind people use websites (video with Sina Bahram, blind accessibility researcher)
Disappointed by Watch Dogs’s graphics ? See how it looks with unlocked, hidden settings. Awesome!
A quick history of Comic Sans, the most wrongly used font ever
laracon-2014-eu-amsterdam
Laracon 2013 – Jordi Boggiano: In Depth Composer (47min video)
php
How to use the PHP 5.5 password hashing functions
How Snapchat wants to earn money (by establishing vertical videos)
How to install/setup latest version of PHPMyAdmin on Ubuntu 12.04 LTS (Precise Pangolin)
phpstorm 7.0 php
How to install GitHub’s, NetBeans’s and Sublime2’s syntax highlighting code colours theme in PHPStorm 6/7

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