PHP Client

Brad Fitzpatrick brad at
Sat Oct 9 20:58:48 PDT 2004

There is no PHP API for MogileFS yet, but one shouldn't be hard to write.
Both the server and client for MogileFS are very simple.  Actually most
the guts of MogileFS are in the HTTP code, which is just Perlbal.

Segway into Perlbal:  it's a:

-- reverse proxy (like plb, etc)
-- web server
-- web server that supports PUT and DELETE, optionally

But it has some tricks, like supporting internal redirects that don't
leave your network.  So imagine that you're using PHP to serve up images
dynamically, but users are on slow modems, and you'd be wasting a PHP
process spoon-feeding the modem user, tying up all that memory for PHP on
the server side.

Instead you can put Perlbal in front, which will advertise via a special
HTTP header that it supports internal reproxying, your PHP application
detects that, does its authentication and URL mapping, as well as MogileFS
client work to find where on the network that image is, then it replies to
Perlbal the locations of the resource that needs to be served.  Then PHP
is free to do whatever, and Perlbal spoonfeeds the client.  Becuse Perlbal
is async/event-based with a single thread, it can handles tens of
thousands of connections at once (as can plb, but plb doesn't do internal

The cool thing about internal redirects is that it makes mod_perl or PHP
not waste their time with things they're not good at, and the whole
process is invisible to the end user.

None of this would be relevant to this list, except MogileFS uses Perlbal
as the HTTP transport.  (it's all hidden though... mogstored, the mogilefs
storage daemon, just uses the Perlbal libraries)

- Brad

On Sat, 9 Oct 2004, Timo Ewalds wrote:

> Hello,
> I code and run . I've got 7 servers right now, and need
> a better way to keep track of all the uploaded pictures (almost a
> million of them now). This looks to be a very cool program that would
> serve the purpose perfectly, but I can't seem to find any way to use it
> from php. Is there a php API for it yet?
> I read your oscon pdf that was posted on slashdot, and found it to be
> very informative and helpful. I am slowly getting to use memcached, and
> am a bit curious as to how perlbal works. Right now I'm just using dns
> forwarding, but would prefer to use LVS, a reverse proxy (plb looks
> good), or something else that allows all servers to respond to one
> hostname. What does perlbal do differently than those two?
> Timo

More information about the mogilefs mailing list