News for hackers. Stuff that matters.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by CWIZO on Monday June 21, 2010 @02:19PM (#1449584)
This has maintainability problems written all over it. I can't imagine a web page where you would actually gain something from this, that wouldn't be complex enough that you wouldn't need some language to deal with more complex selects/inserts. And that would mean that you would spread your logic (models?) across two totally different "platforms". One part in nginx conf file (brrr) and the other in your code. Add something like Sphinx into the mix, and you have your SQL all over the place.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by rbranson on Monday June 21, 2010 @11:51AM (#1449126)
In other news, computer scientists discover that evented C code is faster than PHP.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by kingkilr on Monday June 21, 2010 @01:02PM (#1449349)
This was promptly followed by 6 hours of pedants complaining that that isn't really computer science, but actually software engineering.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by steveklabnik on Monday June 21, 2010 @05:33PM (#1450145)
And hours more spent arguing over if software can even be an engineering discipline or not.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by makmanalp on Tuesday June 22, 2010 @12:00AM (#1450891)
Or whether "Computer Science" can actually be a science in the rigorous sense when it has nothing to do with the scientific method.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by IgorPartola on Monday June 21, 2010 @01:08PM (#1449375)
Why is it only 3-4 times faster is what surprises me. No question that cutting out the PHP interpreter and VM is going to speed things up, but only ever so slightly?
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by ww520 on Monday June 21, 2010 @02:19PM (#1449586)
The speed of MySQL is constant in both cases, and IO is always expensive, thus the CPU speedup via C vs PHP is not as dramatic as one hopes; remove MySQL from the equation and you'll see the gigantic difference.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by piotrSikora on Monday June 21, 2010 @03:09PM (#1449715)
Because it's taken out of the context. Original text says:

"We even observed that ngx_drizzle + ngx_rds_json achieved 128MB/sec (Yes, 1024Mbit/sec!) for a 380KB data-set query while connecting to a simple mysql server, about 3 ~ 4 times as fast as php + libmysql in this setting."

As you can imagine in such scenario (380KB result), MySQL engine is taking the most of the time.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by IgorPartola on Tuesday June 22, 2010 @11:21AM (#1452115)
Good point. Every benchmark is only valid in the context in which it was taken.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by earle on Monday June 21, 2010 @10:19AM (#1448844)
Why is this a surprise to anyone? And Nginx to memcache will be even faster... and serving static content even faster...

You're adding a tremendous amount of overhead with any high level language stuck in between the connect and the data source.

This is about as basic as it gets, not worthy of #1 item on hacker news.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by regularfry on Monday June 21, 2010 @10:27AM (#1448882)
The idea that you might not need the high-level language in the middle at all is interesting in itself. At least, it is to me. I've not seen it before.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by earle on Monday June 21, 2010 @10:36AM (#1448913)
This is working backwards. You do realize that before PHP and higher level languages this is how things generally worked to begin with (server modules) as opposed to now (higher level languages).

I still don't understand why this is on hacker news, let alone the top of the list.. seems to be about the most obvious item of all..

disappointing

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by thwarted on Monday June 21, 2010 @10:50AM (#1448956)
Isn't this still how things work if you want to do anything easily with Microsoft's IIS?
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by wrs on Monday June 21, 2010 @07:09PM (#1450379)
If you're also using Microsoft SQL Server, it essentially has this capability (using XML not JSON): http://msdn.microsoft.com/en-US/library/ms188266(v=SQL.90).a...
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by henrikschroder on Monday June 21, 2010 @12:52PM (#1449321)
Yes, you can write an ISAPI module if you want as little as possible between your program and IIS, but I wouldn't label that as "easily".

And I don't see why you would bother, ASP.Net is compiled, it's not exactly a performance hog, unlike PHP.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by pjscott on Monday June 21, 2010 @03:10PM (#1449720)
I haven't used them, but there are a variety of PHP compilers, like phc or Facebook's HipHop. I hear that they can really speed up PHP code.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by cookiecaper on Monday June 21, 2010 @09:07PM (#1450581)
I can't really tell from the phc page, but HipHop at least doesn't "speed up PHP code". It converts the code from PHP to C++. That isn't speeding up PHP, that's unraveling the PHP and respinning it as C++.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by regularfry on Tuesday June 22, 2010 @07:08AM (#1451523)
It's still speeding up PHP by compiling it, it's just using C++ as an (extra) intermediate representation.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by apgwoz on Monday June 21, 2010 @10:34AM (#1448910)
You haven't seen PHP or Python between MySQL and the webserver? I must be missing your point.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by regularfry on Monday June 21, 2010 @11:51AM (#1449127)
The reverse - I can't remember having seen a database spew JSON from port 80 before without an intervening HLL.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by apgwoz on Monday June 21, 2010 @01:17PM (#1449405)
That makes more sense. Thanks for clarifying.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by buro9 on Monday June 21, 2010 @10:24AM (#1448869)
You're kidding me right? I'm off to re-write my entire app as a stored proc ;)

You are right of course. But what would be nice would be to replace part of a static page with the result of a piece of SQL. To combine ESIs with MySql so that you can serve static files and still be able to add things like watermarks using a MySql lookup based on a session cookie.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by orlandu63 on Monday June 21, 2010 @11:06AM (#1449005)
I'd like to see a benchmark against PHP + mysqlnd (native mysql driver for PHP, which supersedes libmysql as of PHP 5.3)
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by jolan on Monday June 21, 2010 @12:41PM (#1449301)
Ditto, plus another round using facebook's hip hop php compiler.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by k33n on Monday June 21, 2010 @04:09PM (#1449904)
Does anyone actually use that thing? Except Facebook of course.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by jcsalterego on Monday June 21, 2010 @08:47PM (#1450544)
php MCs worldwide yo.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by Lorin on Monday June 21, 2010 @04:39PM (#1450011)
This keeps reminding me to get off my butt and make some sort of passthrough between nginx and mongodb. Yes, I know there's GridFS development but it doesn't suit my needs.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by dylanz on Monday June 21, 2010 @01:13PM (#1449395)
The title of this post is a bit misleading. It's agentzh (who rocks) announcing two new plugins which have plenty of use-cases.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by piotrSikora on Monday June 21, 2010 @03:03PM (#1449698)
Yes, title is definitely misleading. He's not even announcing new modules (both are available for about half year now), he just announced massive performance boost in them.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by jackqu7 on Monday June 21, 2010 @10:12AM (#1448823)
This is really interesting, but I wonder if there is any support for user authentication? Perhaps by combining with basic auth?
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by piotrSikora on Monday June 21, 2010 @03:48PM (#1449819)
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by defied on Monday June 21, 2010 @03:36PM (#1449792)
This should really speed up my website's autocompletion. Not having to load the rails stack will be a big performance boost.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by cdine on Monday June 21, 2010 @11:25AM (#1449056)
So, I get it and all that, what are some real world use cases of this and the postgresql equivalent? Who's actually using these things for something other than saying how fast they are?

I just hope they aren't being used as public-facing JSON API endpoints and the such, since none of them seem to even consider the case of SQL injection. From a quick glance it doesn't seem that any type of parameterized query or prepared statements are available to even begin helping with that, and the "documentation" examples wouldn't be setting people off on the right foot by even limiting the location paths with strict regex's.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by piotrSikora on Monday June 21, 2010 @02:59PM (#1449684)
> Who's actually using these things for something other than saying how fast they are?

Taobao.com (14th biggest site in the world, 3rd in China - according to Alexa) is using ngx_drizzle + ngx_rds_json in production. Qunar.com is using ngx_postgres + ngx_rds_json.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by jbeluch on Monday June 21, 2010 @12:30PM (#1449267)
The example seems to use both regex and set_quote_sql_str to prevent sql injection.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by cdine on Monday June 21, 2010 @02:34PM (#1449634)
Interesting, thanks for the pre-coffee clarification. aka I can't read =]

I'm sure people will still mess things up :)

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by xhuang on Monday June 21, 2010 @06:59PM (#1450364)
removing high level language in the middle is good, if you need performance, why not just use redis to server json directly, in the case you need scale up your db why not use crunchDB.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by llimllib on Monday June 21, 2010 @10:14AM (#1448829)
What is the code in this app written in, I don't really follow?
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by turtle4 on Monday June 21, 2010 @11:05AM (#1449003)
You specify a route in the nginx config, and when the route is requested, it serves up the result of the sql query that you specified. Even further, it looks like it will run different queries, depending on the type of request made (GET, PUT, DELETE).

This just makes it a little easier to put together a RESTful app. Alot of those apps are just thin wrappers around the request that check the request type, check authentication, and then perform a simple db statement. This is easier to define, and apparently alot faster.

Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by piotrSikora on Monday June 21, 2010 @04:12PM (#1449917)
Yup, that's exactly the idea here :)
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by apgwoz on Monday June 21, 2010 @10:19AM (#1448850)
It seems as though you write the SQL in the nginx conf... Not sure if it's then somehow available elsewhere.
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by executive on Monday June 21, 2010 @10:11AM (#1448817)
can this be used with PHP though?
Re:Nginx directly to mysql. 3 - 4 times as fast as php + lib... by spooneybarger on Monday June 21, 2010 @10:37AM (#1448915)
the entire point is to remove php/perl/ruby etc from the equation.