# Ngx\_drizzle v0.0.11 and ngx\_rds\_json v0.09: significant performance boost

**URL:** <https://www.ruby-forum.com/t/ngx-drizzle-v0-0-11-and-ngx-rds-json-v0-09-significant-performance-boost/190477>\
**Category:** NGINX\
**Created:** [June 21, 2010, 11:25am UTC](https://www.ruby-forum.com/t/ngx-drizzle-v0-0-11-and-ngx-rds-json-v0-09-significant-performance-boost/190477 "2010-06-21T11:25:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![agentzh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@agentzh](https://www.ruby-forum.com/u/agentzh)\
**Post date:** [June 21, 2010, 11:25am UTC](https://www.ruby-forum.com/t/ngx-drizzle-v0-0-11-and-ngx-rds-json-v0-09-significant-performance-boost/190477/1 "2010-06-21T11:25:28Z")

</div>

Hi, folks!

I’m happy to announce that ngx\_drizzle v0.0.11 and ngx\_rds\_json v0.09  
are finally out:

```
http://github.com/chaoslawful/drizzle-nginx-module/tarball/v0.0.11

http://github.com/agentzh/rds-json-nginx-module/tarball/v0.09

```

ngx\_drizzle is an upstream module that talks to mysql, drizzle, and  
sqlite3 by libdrizzle, and generates output in a binary format known  
as RDS (Resty DBD Stream), just like Piotr S.'s ngx\_postgres  
module.

ngx\_rds\_json is an output filter module that converts the RDS outputs  
of ngx\_drizzle and ngx\_postgres, to plain JSON text.

The highlight of these releases are _significant_ performance boost  
due to extensive refactoring and optimizations in these two modules  
recently.

One can observe hundreds of times of improvement for big responses  
above 300KB for both ngx\_drizzle + ngx\_rds\_json and ngx\_postgres +  
ngx\_rds\_json combination.

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.

Technically, we (partially) adapted the “fixed-size bufs” model used  
in ngx\_http\_gzip\_filter\_module (and elsewhere in the nginx core) in  
both of our modules, effectively eliminating lots of unnecessary  
packet splitting and buffer allocations, which contributes most of the  
performance boost. And we’d like ngx\_postgres to apply this technique  
in the near future too (for a typical 470 KB data-set query,  
ngx\_drizzle + ngx\_rds\_json is now more than 50% faster than  
ngx\_postgres + ngx\_rds\_json).

We also introduce the drizzle\_buffer\_size and rds\_json\_buffer\_size  
directives to allow the user adjust the size of each buf that is used  
in the output emitter:

```
 drizzle_buffer_size 4k;
 rds_json_buffer_size 4k;

```

The default setting is the page-size, usually 4k ~ 8k. The bigger the  
buffer size, the less streamming the output will be.

At last but not least, this release of ngx\_drizzle also includes  
various new features ported from ngx\_postgres, like the  
“method-specific queries” support in the drizzle\_query directive.

Here’s an example that implements a full RESTful interface to a mysql  
backend using a single nginx location, and no “if hacks”:

location ~ ‘^/cat/(\d+)’ {  
set $id $1;  
set\_form\_input $name;  
set\_quote\_sql\_str $quoted\_name $name;

```
   drizzle_query HEAD GET "select * from cats where id=$id";
   drizzle_query DELETE "delete from cats where id=$id";
   drizzle_query POST "insert into cats (name) 

```

values($quoted\_name)";

```
   drizzle_pass my_mysql_backend;

```

}

There’s also an example for ngx\_postgres in my slides:

```
http://agentzh.org/misc/slides/recent-dev-nginx-conf/#18

```

Have fun!  
-agentzh
