nginx - Perl improve performance of generating 1 pixel image -
hi need generate 1x1 pixel image in perl, can fastest way generate this. assuming getting 10k connections/per second on web server.
currently using :
print mime::base64::decode("ivborw0kggoaaaansuheugaaaaeaaaabaqmaaaal21bkaaaabgdbtueaalgpc/xhbqaaaazqtfrf////aaaavcltfgaaaaf0uk5taedm2gyaaaabykthracibr1iaaaacxbiwxmaaassaaaleghs3x78aaaab3rjtuuh0gqcex05cqka8gaaaapjrefuejxjyaaaaaiaauivpheaaaaasuvork5cyii=
i cannot host static file, need process request data.
thanks kathiresh nadar
first off, high performance perl should using fastcgi (via fcgi
module directly, or cgi::fast
wrapper) or mod-perl or other technology make script stick around persistent process in memory.
secondly, if you're processing request other data first , involves writing file or talking database or that, time dominated processing. generating image not slow part.
but let's answer question anyway: assuming using keep-the-script-in-memory technology, first thing can move mime::base64::decode
call begin
block, store result in variable, , use variable.
but also, sending image on wire going take longer processing on server, why sending 167 bytes of png when sending 42 bytes of gif? put both of pieces of advice together, , get:
my $gifdata; begin { $gifdata = mime::base64::decode( "r0lgodlhaqabaiaaaaaaap///yh5baeaaaaalaaaaaabaaeaaaibraa7"); } print $gifdata;
Comments
Post a Comment