[2nd try] PHP client question: why socket_create()?

Ryan T. Dean rtdean-lists-memcache@cytherianage.net
Wed, 8 Oct 2003 14:50:05 -0400


--+pHx0qQiF2pBVqBT
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 08, 2003 at 01:46:57PM -0400, Justin Matlock wrote:
> Wow.. okay.   I like your API much more than the old one I've been hacking
> on.     *worship*    :-)

   Thank you.  All props to Brad et al for all the logic used in the=20
client; so far all I've done is an implementation using their logic for=20
everything.  I'll have some additional PHP-related stuff (turning it=20
into a PEAR module, tossing intelligent errors, etc) in the next week or=20
two.  Just need to finish up this project I'm working on.

> But.... It's crashing my apache process threads at an alarming rate (maybe
> 10-15 per minute)...  it's probably the same funky bug in PHP that I was
> seeing with my client.  The latest PHP CVS works great, though, and I don=
't
> see any crashes.

   That is extremely... odd.  I've started to look through the PHP bug=20
log and see if I can't account for this in there.  I'll also try to=20
duplicate it here, and then track down exactly where it is happening.

> I'm seeing some increases in speed due to the persistant connections.  I =
had
> to do some tweaking to my apache processes to make sure they didn't overl=
oad
> my memcached servers, though -- for some weird reason, PHP is leaving *so=
me*
> sockets open, when it should be closing them at the end of each script.  I
> can't figure out a pattern to this yet, but I haven't looked at it too lo=
ng.

   If you are setting persistant to true in your init statement, you are
using persistant connections.  Persistant connections are just that... =20
persistant... they should persist between script executions.  The speed
benefit gained from using persistant connections is in the fact that you
don't have to reestablish the connection every run.  As a general rule,
using persistant connections, expect a connection from every child
process to every memcached server.  So, if you are running a single
webserver with a max of, say, 100 children, expect 100 connections to
each memcached server.  Once the script has been run on every child,
until a child terminates (voluntarily or not), no new connections should
have be to created - the existing connection should be used.

> As always, results may vary; it may be working flawlessly for someone els=
e.
> Afterall, I'm using a very tweaked out configuration...
>=20
> './configure' '--with-apxs2=3D/opt/httpd/bin/apxs' '--prefix=3D/opt/zend'
> '--with-msession' '--enable-trans-sid' '--enable-memory-limit'
> '--enable-inline-optimization' '--enable-wddx' '--with-gd'
> '--with-openssl=3D/opt' '--with-zlib=3D/opt' '--enable-bcmath'
> '--enable-calendar' '--enable-ctype' '--enable-exif' '--with-ttf'
> '--with-ldap' '--with-ming=3D/opt' '--enable-sysvsem' '--enable-sysvshm'
> '--with-jpeg-dir=3D/usr' '--with-png-dir=3D/usr' '--with-zlib-dir=3D/usr'
> '--with-freetype-dir=3D/opt' '--with-zip=3D/opt' '--with-mcrypt=3D/opt'
> '--with-mhash=3D/opt' '--enable-gd-native-ttf' '--with-mysql=3D/usr'
> '--enable-ftp' '--with-pspell=3D/opt' '--enable-sockets' '--enable-tokeni=
zer'
> '--with-config-file-path=3D/opt/httpd/conf' '--with-curl=3D/opt' '--enabl=
e-cli'
> '--with-imap=3D../imap-2002.RC7' '--with-gettext' '--with-dom=3D/opt'
> '--with-bz2' '--with-imagick=3D/opt' '--with-mime-magic' '--with-snmp=3D/=
opt'
> '--with-ucd-snmp-hack' '--enable-stem' '--enable-pcntl' '--enable-posix'
>=20
> with apache 2.0.47
>=20
> '--prefix=3D/opt/httpd' '--enable-auth-digest' '--enable-deflate'
> '--enable-logio' '--enable-mime-magic' '--enable-cern-meta'
> '--enable-expires' '--enable-headers' '--enable-unique-id' '--enable-ssl'
> '--enable-info' '--enable-speling' '--enable-rewrite' '--enable-so'
> '--enable-vhost-alias'  '--with-mpm=3Dprefork
>=20
> along with turck mmcache 2.3.23 (replaces Zend Accel.), on top of Zend
> Optimizer v2.1.0, and finally with mod_perl.  (whee!)

   The box I'm testing on here is apache 1.3.28 + php=20
4.3.{4.rc1,3,2.rc4} with the following config:

'./configure' '--enable-versioning' '--enable-memory-limit'
'--with-layout=3DGNU' '--with-zlib-dir=3D/usr' '--disable-all'
'--with-regex=3Dphp' '--with-pear' '--with-apxs=3D/usr/local/sbin/apxs'
'--enable-bcmath' '--with-bz2=3D/usr' '--with-cdb' '--enable-ctype'
'--enable-dba' '--with-dom=3D/usr/local' '--with-dom-xslt=3D/usr/local'
'--with-dom-exslt=3D/usr/local' '--enable-ftp' '--with-gd'
'--enable-gd-native-ttf' '--enable-gd-jis-conv'
'--with-freetype-dir=3D/usr/local' '--with-jpeg-dir=3D/usr/local'
'--with-png-dir=3D/usr/local' '--with-gettext=3D/usr/local'
'--with-iconv=3D/usr/local' '--with-inifile' '--with-mcrypt=3D/usr/local'
'--with-mhash=3D/usr/local' '--with-mime-magic=3D/usr/share/misc/magic.mime'
'--with-mysql=3D/usr/local' '--with-ncurses=3D/usr' '--enable-overload'
'--with-pcre-regex=3Dyes' '--enable-posix' '--with-readline'
'--enable-session' '--enable-sockets' '--enable-sysvsem'
'--enable-sysvshm' '--enable-tokenizer' '--enable-wddx' '--enable-xml'
'--with-expat-dir=3D/usr/local' '--with-xmlrpc' '--enable-xslt'
'--with-xslt-sablot=3D/usr/local' '--with-zip=3D/usr/local'
'--with-zlib=3Dyes' '--prefix=3D/usr/local' 'i386-portbld-freebsd4.9'

   I'll write a test script and pound on it for a bit to try and get=20
apache to crash.

   As a side note, there were a few errors in client 0.1.  I've released=20
0.1.1; its available at=20
http://www.cytherianage.net/~rtdean/memcached-client-php-0.1.1.tar.gz. =20
You may want to try that, and see if its any better.

          -Ryan T. Dean

--+pHx0qQiF2pBVqBT
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/hFxdW6VZzwycJGURAnanAKCfw05g07YqdoOacsQCBCb0/7WoigCgulmB
9yDddUuF8tE+0qAT+vd6Gm0=
=NuN+
-----END PGP SIGNATURE-----

--+pHx0qQiF2pBVqBT--