Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Nov 10, 2008 8:56 pm 
Offline
Senior Member
User avatar

Joined: Sun Aug 10, 2008 11:26 am
Posts: 104
Location: ~$
I'm designing a web app that generates imagery based on lots of spatial data, processing up to 100k data points per image. Ideally, this will happen in something close to realtime. I've implemented this in PHP with GD, and it takes about .6 seconds for the worst case, way too slow.

I'm still tweaking the algorithm, but what most people have told me is to get closer to the hardware and write the CPU-intensive part in C. Makes sense, and I can write the C code, but I'm not sure about how to make it fit with the rest of the site, which is written in PHP. Should I call it directly as a CGI program? Would it work to invoke it as a system() call from PHP? The latter would be more convenient for me, but I don't know if would be a performance hit.

I'm running Apache 2.x. Thanks for any advice.


Top
   
 Post subject:
PostPosted: Tue Nov 11, 2008 6:55 am 
Offline

Joined: Sat Oct 18, 2008 7:17 am
Posts: 1
A third option is to write your own PHP extension. This will give you the performance of compiled native code, without the hassle of calling an external application.


Top
   
 Post subject:
PostPosted: Tue Nov 11, 2008 7:37 am 
Offline
Senior Member

Joined: Fri Feb 18, 2005 4:09 pm
Posts: 594
For scientific and engineering work, I call C and C++ from within Python as a compiled extension - definitely far faster than any other method, and compute speeds are very high for well-written C/C++ routines.

James


Top
   
 Post subject:
PostPosted: Tue Nov 11, 2008 1:15 pm 
Offline
Senior Member
User avatar

Joined: Sun Aug 10, 2008 11:26 am
Posts: 104
Location: ~$
Wow, thanks to both of you - I didn't know that was an option. Looks like it's definitely the way to go. I found a guide— http://devzone.zend.com/node/view/id/1021

Guess I'll roll up my sleeves and try to build this thing. Any tips from those who have done this before?


Top
   
 Post subject:
PostPosted: Tue Nov 11, 2008 2:17 pm 
Offline
Senior Member
User avatar

Joined: Sun Feb 08, 2004 7:18 pm
Posts: 562
Location: Austin
Doesn't mod_php would give you the benefits of pre-compilation? That would surely be the easiest.


Top
   
 Post subject:
PostPosted: Tue Nov 11, 2008 3:19 pm 
Offline
Senior Member
User avatar

Joined: Sun Aug 10, 2008 11:26 am
Posts: 104
Location: ~$
Xan wrote:
Doesn't mod_php would give you the benefits of pre-compilation? That would surely be the easiest.


Perhaps easiest, but you'd still be writing the algorithm in a highly-abstracted (slow) language. Much faster to do it in C.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group