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

Ilia Alshanetsky's Blog: Reliably locating phpinfo()

Matt Curry's Blog: 8 Ways to Speed Up CakePHP Apps

phpaddiction: Url Routing with PHP - Part Two

SitePoint PHP Blog: Using Solarium with SOLR for Search Implementation

Sebastian Nohn's Blog: PHP on Cruise - Assuring compatibility with new PHP versions


Community Events





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


refactor unittest introduction podcast framework configure developer list wordpress language opinion install code community interview testing series laravel release threedevsandamaybe

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