About a year ago I was asked to fix a very serious performance issue of a tourism-related website which normally had about a few thousand visits a day. When I first met the owner he was ranting for half an hour about how he doesn't trust developers because thery are all unreliable etc. The website was written in PHP and used PostrgreSQL as database backend. The problem was that the server kept crashing every few hours and was generally very slow. The sysadmin of the server suggested the owner to buy an even more powerful server with more RAM to solve the problem. Now I am not really a web developer and I don't have much experience with PHP and these kind of systems but I was the only programmer the owner could get. After digging through the problem and some testing I realized that the website actually couldn't handle more than 4-5 visit per minute, and the server was overwhelmed with only a few hundrends of visits easily. The first thing I noticed that actually the website pulled *every* *single* *line* of text on the website from the database. This sounds WTFish for me, but the sysadmin ensured me that that's the way websites work, and since I'm not experienced with web development, I don't know if that's true or not. None the less, PostgreSQL should be able to handle a few hundred queries a minute, so that shouldn't be a problem. Now the real WTF was that I realized that before every single page load the PHP scripts pulled every single line (>100000 lines) from the database, put them into an array (and if I remember correctly, PHP arrays are hashtables as well in the same time), and then looked them up from the array at the appropriate locations. If it were up to me I would have just put all the text inside the PHP files, but since it was a quite large website and this "logic" was deeply rooted in every PHP file, I had to find an other solution. Unfortunately time and cost constraints didn't allow me to rewrite the whole mess. My solution was to create an inherited class of the inbuilt PHP array class which only pulled any line of text from the database when it was required (or if it was required), and then cached them with memcached. There might be a better solution, I don't know, as I mentioned, I am not a web developer, but my solution worked perfectly and after I introduced my changes to the live system (there were no version control, of course), everything was fine. No crashes and slowdowns anymore. On the side note, the owner of the website started blaming me for some other disasterous aspects of the website right after I fixed the speed issue and it started to get a bit personal, so I decided that the whole headache didn't worth it. Long story cut short, I have never got payed for the fix. Last time I heard about the guy he was trying to hire a web devlopment agency to do the job and clean up the website
D
Best posts made by DrJokepu
-
Realy dynamic website
-
RE: Mashup Challenge $100,000 prize - WTF if Spectate Swamp wins?
@SpectateSwamp said:
I didn't make that rediculous statement ...
-
RE: Forum Guidelines Discussion
I am way too lazy to edit that, but basically that's my opinion:
[23:01] <DrJokepu> my problem with phil's list that the whole point of sarcasm that you don't tell it's sarcasm. it's like an iq-test. tagging sarcasm with </sarcasm> is plain faggotry i think [23:01] <mps> dr, stfu noob [23:01] <mps> DrJokepu: was that sarcasm? [23:02] <DrJokepu> ^_^ [23:02] <hedonismbot> no u! [23:02] <drjokepu> was that sarcasm? [23:02] <mps> DrJokepu: your face is sarcasm, fgt [23:02] <morbz> DrJokepu: I agree. [23:03] <mps> I just dislike coddling people [23:03] <mps> I think we should expect a certain level of intelligence on the forum [23:04] <mps> of course that doesnt explain why morb is here [23:05] <morbz> DrJokepu: Can you imagine if Jonathan Swift had been like "Begin sarcasm.." [23:05] <ammoq> DrJokepu: why don't you post your opinion about the sarcasm-tag in phil's thread? I'm sure many people agree with you.