Reply to Re: [PHP] Very high speed session management -- help me test

Your name:

Reply:


Posted by Mark on 10/20/04 11:36

Jochem Maas wrote:

> Mark wrote:
>> Jochem Maas wrote:
>>
>
> ....
>
>>
>> That's sort of the problem with names, it is hard to convey ideas. MCache
>> (formally msession) has a history. I originally wrote the code as a way
>> to
>
> there is a php extension called 'mcache' with is a wrapper for memcache -
> but this is not the same as your tool right? in which case I doubly
> recommend another name :-)
>
>> share data for a beowulf cluster. Later on I was working on a site that
>> had
>
> the words 'cluster' may very well be something to think about .. e.g.
> 'ClusterCache'

Interestring. I'll consider something like that. BTW a C/C++ API is still
available and supported for beowulfs.

>
>> multiple PHP web servers and realized it was the exact same problem
>> domain. Multiple machines at any one instant mostly working on different
>> data but requiring access to serialized shared data or a central store of
>> data.
>>
>> This is a HUGE problem once you get past one PHP server. Even with one
>> server you still need a database to manage your poll. You can't do this:
>>
>> $var = sql->exec("select poll_count from poles where pollid='foo' and
>> name='bar'";
>> $var++;
>> $var = sql->exec("update poles set poll_count = $var where pollid='foo'
>> and name='bar'";
>>
>> In an active site you will have concurrency issues and lose counts even
>> on a single machine.
>>
>> So you'll have to do something like this:
>>
>> sql->exec("update polls set poll_count = poll_count+1 where pollid='foo'
>> and name='bar'";
>>
>> $var = sql->exec("select poll_count from poles where pollid='foo' and
>> name='bar'";
>>
>> That is *always* two database operations. Best not get slashdotted! With
>> MCache, it works like this:
>>
>> $var = mcache_inc("foo','bar');
>
> that is nice... :-)

being from Boston MA, it's "wicked" nice, that little gem is the crux of one
of the problems that needs solving.

>
>>
>> Now, depending on your strategy, there will may be no hits your database
>> or (at most) one. How many times have you seen a site DOA because the
>> database (typically MySQL) has crapped out?
>>
>> MCache on a modern computer, handling the session storage and retrieval,
>> and a one or two variable calls like the above, can handle (depending on
>> session size, network speed, etc.) upwards of 5000 operations a second.
>> It is designed to be fast!!! Granted, if the session information is
>> larger than one TCP/IP packet, it is slower, but still way faster than a
>> database.
>>
>
> I just checked some session file sizes on a 'heavy' site I built. the
> largest file was 332607 bytes; which very roughly speaking would require
> about 220 packets.
>
> is such a large session file feasible with you tool? (regardless of
> whether one might suggest that I have a design flaw in the site in
> question)

Well, here are the limitations: There are two versions of the protocol, and
ascii and binary protocol, the ascii version used to be limited to about
1M, but with changes made to mcache, it supports up to about 14M (Some bozo
complained that 1M wasn't enough for their session information!!!). The
binary protocol requires the mcache machine to have the same binary number
representation as the client machine. Using the ASCII protocol, mcache
could be on a Mac or Solaris machine while web servers run x86 Linux, you
lose that with the binary, but you could, theoretically have a session
that's a little less than 2G.

Remember, however, that mcache keeps things in RAM!!! Garbage collection
helps, but with your session size, the total number of active sessions
would be limited to about six thousand (approx 2G) on a 32bit MCache
server.

And yes, when I eventually get a 64bit Linux machine, I'll make sure it
compiles native 64bit. (Anyone want to buy me a kick-ass 64Bit machine for
development :-)


>
>>
>>
>>
>>>>
>>>>>is this better than using the 'files' session handler and setting the
>>>>>session save path to a tmpfs filesystem (in effect a RAM disk) in a
>>>>>signle server env.?
>>>>
>>>>
>>>>This is not really intended for a single server site, but could provide
>>>>some benefit as a way of abstracting file or SQL session storage.
>>>
>>>ok; although that doesn't answer my question.
>>>another thing if it's not really intended for a signle server site then
>>>youre audience here is rather limited - I'm guessing that there are not
>>>many here running distributed/load-balanced systems.
>>>
>>>I don't atm; but it almost makes me want to go out and get a server
>>>to try it out.
>>
>>
>> Well, using the poll operation detailed above, you can see relative
>> advantages. It is faster than the PHP file based sessions. It can
>> periodically save session data. It does its own garbage collection. It
>> can be used to call external functions. It will eventually (there now,
>> needs testing and debugging) even have a SQL based write through caching
>> plug-in that will allow an amount of database abstraction, or even
>> session storage abstraction.
>
> I for one will definitely be watching your space :-)

Click some ads while you are at it. For about 6 years msession has made me
no money. Wasn't too big a deal as I have clients, but last year was pretty
slow. I started thinking that while it was slow I should use my spare time
to improve and promote my open source project separate from my consulting
business. So, while I have a number of open source projects (written to
solve specific problems), I didn't really have a logical place to put them.

I started mohawksoft.org to concentrate only on my open source stuff and
maybe get decent google add revenue from traffic. Donations certainly
haven't worked, and no one pays for support. One company actually called me
on a Sunday night with an emergency! and no, they didn't even send a
donation!

>
>>
>>
>>>>>>the word out and get some testers.
>>>>>>
>>>>>>The server itself is GPL, the PHP extension is under the PHP license.
>>>>>>I will be checking it in to the PHP main CVS repository when I'm
>>>>>>pretty sure that it will play nice.
>>>>>>
>>>>>>The server can be accessed via CVS from www.mohawksoft.org.
>>>>>>
>>>>>>If you have any questions please feel free to ask.
>>>>>>
>>>>
>>>>
>>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация