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

How Snapchat wants to earn money (by establishing vertical videos)

Snapchat is worth 15-19 billion dollars. An insane number, making everybody ask: How the hell is this possible, why has

twig

A 6min video introduction into Twig, the PHP templating engine

Cool video, excellently explained. Just 6 minutes, but features all the basics. Note that you can integrate Twig into your

photoshop-cc-deal

Adobe offers Photoshop for $9.99 per month (limited deal)

Currently Adobe offers the very latest version of Photoshop (which is Photoshop CC) for just $9.99 or 12,99€ (EU zone:

php

How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)

Please note: This works fine. But this package will also upgrade your apache to version 2.4 which has different config

php

Test out PHP 5.6alpha1 on Windows 7 / 8 with two clicks

The popular Apache-MySQLP-PHP stack EasyPHP has become very professional, maintained and especially modularized in the last 2 years, and when

redaktionelle-hochlastseiten

Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)

Eine grandiose Powerpoint-Präsentation die sich jeder, der mit PHP, MySQL und Apache auf Linux arbeitet, mal anschauen sollte: Nils Langner,

vagrant

A super-simple Vagrant LAMP stack bootstrap (installable with one command)

As I have to setup servers inside Vagrant quite often, sometimes 10 times per day, I started to use provisioning:

composer

The difference between “composer install” and “composer update” – nailed on the head

What a beautiful, direct and clean explaination of the often-confusing difference between composer install and composer update: Beau Simensen (Twitter,

How to get a single table out of a massive MySQL .sql database backup file (mysql dump splitter)

Imagine the following situation: Somebody backs up an entire MySQL database – a very large one – with common tools.

Hacking ATMs – A conference talk about the current security state of Windows XP driven cash machines

A few days ago the 30th edition of Germany’s Chaos Communication Congress took place, a high-profile event for IT-security and

1/4

Categories

Search

PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)
php uk conference
PHP Caching Best Practices by Eli White (video from PHP UK Conference 2014)
php
How to prevent PHP sessions being shared between different apache vhosts / different applications
phpstorm-8
Ignore .idea folder from git in PHPStorm
Dangerous Performance Myths in the Web (video talk by Thomas Lohner, PHPUG Latvia)
php-legacy-code
Interesting talk on modernizing a legacy PHP codebase
php uk conference
Profiling PHP Applications by Bastian Hofmann (video from PHP UK Conference 2014)
hiphop php
HipHop VM reaches 100% green Unit Tests in Laravel, Drupal, Slim, CodeIgniter etc.
How to setup a config-free WordPress, PHP and MySQL (for local development) in Windows 7 / 8 in under 3 minutes
Soundcloud’s “VP of Engineering” about using SSDs
phpstorm-8
Killer-feature in PHPStorm: Search everywhere
increase-your-pagespeed-score
Increase your PageSpeed score (10min video with Matt Gaunt)
mod-rewrite-ubuntu-14-04-lts
How to enable mod_rewrite in Ubuntu 14.04 LTS
php
How to use the PHP 5.5 password hashing functions
[Link] Redesigning SoundCloud by Evan Simoni

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