News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Nikita Popov:
Fast request routing using regular expressions
February 19, 2014 @ 09:03:07

In his latest post Nikita Popov talks about routing and regular expresions. He also shares some work he's done to create a fast request router using them in "userland" code instead of a C extension.

Some time ago I stumbled on the Pux routing library, which claims to implement a request router that is many orders of magnitude faster than the existing solutions. In order to accomplish this, the library makes use of a PHP extension written in C. However, after a cursory look at the code I had the strong suspicion that the library was optimizing the wrong parts of the routing process. [...] To investigate the issue further I wrote a small routing library: FastRoute. This library implements the dispatch process that I will describe below.

He includes some benchmarks against the results from a C-based routing engine showing his solution performing slightly better. What he's really talking about, though, is the dispatch process in general, not just his implementation. He talks about "the routing problem" many engines face - having to loop through a potentially large set of routes to find a match. He offers an alternative using regular expressions and compiling all of the routes down into one large expression. He includes a simple implementation of the method and reruns the same benchmarks with some different results. He offers one potential solution for speeding it up using "chunked expressions" to break it down into more manageable matching. He includes benchmarks for this last solution as well, showing a slight improvement.

0 comments voice your opinion now!
regularexpression routing dispatch engine chunk compile

Link: http://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html

blog comments powered by Disqus

Similar Posts

Elizabeth Smith's Blog: How to Compile PHP5.2 and PHP-GTK2 on Windows using Visual C++ Express

YoungCoders.com: Debunking the Bloated Smarty Myth

PHPFreaks.com: PCRE Regex Spotlight: \K

Hiveminds Magazine: Microsoft is in control of the PHP and Apache projects?

Christopher Kunz's Blog: Building PHP with cURL and libmysqlclient5


Community Events





Don't see your event here?
Let us know!


podcast bugfix symfony install series framework voicesoftheelephpant list package community language tips laravel api library release interview opinion introduction deployment

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework