User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Q about hosting for processor intensive php Page [1]  
plaisted7
Veteran
499 Posts
user info
edit post

I'm a newb to PHP for the most part (Just started using a month or two ago) and have some questions regarding hosting. Currently I'm with some cheap ass hosting that has php 4.1 (going to switch soon because I need php5 for easyXML stuff).

Some of my PHP files I'm writing are very processor intensive (if thats the right way to say it). Some of the scripts are design scripts looping until all checks are met. Even worse I have some PHP scripts for simulations that might go through a While statement a couple million times. Also some search functions I've written to go through databases could be a problem. If these are run several thousand times a day I could imagine that being noticable.

Is this normal and most servers are powerful enough to not even notice this sort of thing. Do some hosts limit how much processing power the PHP can use and might require you to get a dedicated box? This is new to me as I've always thought of hosting in terms of storage space and bandwidth allowed but now concept of computing power is coming up. I know I could have these be some sort of downloadable file, or write them as a java applet but I want to avoid that.

Basically I'm just wondering if it's something I should worry about. Thanks

6/6/2007 4:30:44 PM

bous
All American
11215 Posts
user info
edit post

you'd need to do dedicated hosting.

6/6/2007 4:34:47 PM

Noen
All American
31346 Posts
user info
edit post

yep, you are going to get bumped to a dedicated plan or have your account suspended quickly on a shared platform. Best bet if possible is to use your local pc and a local copy of apache to run the scripts, then push the results to your shared hosting site.

6/6/2007 5:07:20 PM

qntmfred
retired
40556 Posts
user info
edit post

you might want to ssh in to the server and run the top command to see just how intensive your scripts really are. you might not have anything to worry about in the first place

6/6/2007 5:22:43 PM

agentlion
All American
13936 Posts
user info
edit post

^ yeah, was thinking that too.
You may think your database queries that occur "a couple thousand times per day" are CPU intensive, but it could be that the server handles them with no sweat. For the simulations? eh, dunno.

not to mention - you could probably look for ways to optimize your code so that it runs leaner and faster

6/6/2007 5:28:51 PM

LimpyNuts
All American
16859 Posts
user info
edit post

What is it that your scripts are doing? What legitimate reason could you have for "looping until all checks are met". If it's checking for something that's beyond control of the script, it'll just chew up CPU cycles pointlessly. If you're testing for the completion of something, why not have a client-side script that checks back every 1 or 2 or 5 or 10 seconds and tells the user the result.

What kind of "simulations" are you running. Consider if these would be better off as a server process and a separate script that interfaces with it.

These may not be problems if you only have a couple users. What if your simulation was running 1,000 times at once by 1,000 different users? Or if one person erroneously (or deliberately -- read DoS) initiated it several times?

6/6/2007 5:37:30 PM

plaisted7
Veteran
499 Posts
user info
edit post

By looping until all checks are met I meant internal checks. That one specifically is a simple engineering design program and the checks are just design formulas and the program loops trying to increase certain dimensions logically.

Some of the simulations are particle interaction and the likes.

I'm probably just going to convert most of the scripts to javascript so it'll be client side computations. Has some downsides in ways but it'll be nice not to have to worry about the processing power. Of course scripts that interface with databases will have to mostly be php but those aren't the most processor intensive.

6/6/2007 6:06:48 PM

LimpyNuts
All American
16859 Posts
user info
edit post

What kind of particle interactions? Like Monte Carlo? That kind of code should not be written in PHP or JavaScript as interpreted code runs slow. If your calculations aren't too complex Java should perform well (as much as I'm not a fan of Java). Otherwise it may be worth it to produce a server-side or client-side application. Server-side applications have the benefit that the client's platform is irrelevant, so you don't have to worry about it working for some people and not for others.

6/6/2007 11:26:48 PM

bous
All American
11215 Posts
user info
edit post

sounds like this falls out of the scope of a simple scripting language.

6/7/2007 10:12:03 AM

plaisted7
Veteran
499 Posts
user info
edit post

No nothing that complicated. It's a particle based soil consolidation model I'm playing around with. I'm not too worried about speed on these. It's nothing professional. When I was in undergrad I wrote a lot of scripts (some just in excel, vbscript ) to do design problems or something simple like calculating the moment of inertia of objects. If I could write a script to solve the problems that worked I knew I understood the concept fully so it was a win win.

I decided I'd try to put them online for people to use since they were well received from the people who saw them. This seemed like a simple way to put them online so I've been converting them to PHP in my free time at work. PHP is really straightforward for the things I was using it for but I didn't really think about my hosting service gettign pissed off. I also wrote some scripts for world of warcraft (it gets really slow sometimes at work and I guess I'm a huge nerd) that have become fairly popular and get a couple thousand runs a day. If each view does 50,000 loops it can add up I guess.

Anyway for most scripts I think javascript will do fine. I haven't written anything in it in over 5 years but from what I can remember it'll be ok. So what if they run really slow, it's a free script.

6/7/2007 10:13:22 AM

Noen
All American
31346 Posts
user info
edit post

50,000 loops can be trivial or it can be ridiculously intensive.

Put an apache server on your local machine and run AB (apachebench) on it to see what the processing times are. Or you should be able to look at your server logs to see how long each page is processing, which should at least give you some clue as to CPU time.

6/7/2007 1:12:37 PM

 Message Boards » Tech Talk » Q about hosting for processor intensive php Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.