Jump to content
xisto Community
Sign in to follow this  
arp240

Server-friendly Php Scripts

Recommended Posts

Hi I'm relativly new to php... I'm interested in writing server-friendly php scripts and i was wandering in what cases php scripts are harmfull to server i runs on... i was thinking about issues like: * Which php functions are expensive from the point of view of server's performance and resources? * What is considered to be a long array in php context if ,say, each record is 100 bytes long? (100+ element ? a few thousands?) * Are there some assumptions that php programmer should avoid? (comes to mind this example:

http://forums.xisto.com/no_longer_exists/) * I working on my own little and simple database using b+ trees (index data structure). It is being written with php. The thing that warries me is disk access... Will it be noticable for server or not :) For example, to serve forum page with 25 posts it will require ~30 disk access(each one preceded by appropriate seek operation) 25 of these are to read all 25 posts and the rest are for internal houskeeping. I know that real databases will probably do even more work and take a lot more resources but the difference is that real db can handle the request asynchrounelsy(server can do other things in between) and real db executing much faster than parsing and iterpreting php script) * I will be glad to hear anything else that i didn't think about... thanks

Share this post


Link to post
Share on other sites

It all depends on the server, if you have a good / fast strong server, it processes much faster. You can't give a hard limit of what is much, because that's different for each server.I don't think you have to worry much, servers today are quite powerfull

Share this post


Link to post
Share on other sites

hmm, i guess there are ways that php can be somewhat harmful to the server you run on, but like jipman said, I doubt that a code can mess with the server too much unless it is doing some infinite loop or something. They're pretty high-tech nowadays ^_^

Share this post


Link to post
Share on other sites

The only real damage is from improperly permissioned or owned files. Register globals is only available from a server config so you can't turn it on from a script. Most databases cache the most used sql statements. Now I don't know how much that is done with MySQL but they aren't as taxing on a hdd as you might think.

Share this post


Link to post
Share on other sites

Well one thing that people often forgets when dealing with HTML (or whatever) outputting scripts is that which the scripts (program wise) are usually quite simple and with modern machines run very fast, but it's the I/O that is the slow thing. So instead of doing like a million echo calls, it's faster to group your stuff together and do just few echos.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.