Live data from Hacker News

Ask HN: matrix multiplication within PHP?

news.ycombinator.com

1–6 of 6 posts

Ask HN: matrix multiplication within PHP?

#1
I am implementing a PHP-based web site that includes a simple recommender system. The key numerical calculation is a matrix multiplication. I am worried that doing this in PHP might be painfully slow. Does anyone else have experience doing numerical computations in PHP? I looked at writing my own PHP extension ( http://www.tuxradar.com/practicalphp/20/0/0 ) to implement matrix computations in C, ... but then it struck me someone else must have already encountered and solved this problem.

Any recommendations?

Re: Ask HN: matrix multiplication within PHP?

#3
From my experience, numerical algorithms at all complicated in PHP tend to lead to major suckage. We use Thrift (http://incubator.apache.org/thrift/) to send the task to a daemon written in something more reasonable, most often either Python or C depending on required intensity. Works beautifully, few problems. Also, this lets you run the task asynchronously, so you can still return the page in N ms and then load the results on a lag: responsivity means a huge amount to users. Nothing's worse than the script dying from memory limits or timeouts and having the user get nothing (and PHP doesn't do threading).

Re: Ask HN: matrix multiplication within PHP?

#5
post #3

From my experience, numerical algorithms at all complicated in PHP tend to lead to major suckage. We use Thrift ( http://incubator.apache.org/thrift/ ) to send the task to a daemon written in something more reasonable, most often either Python or C depending on required intensity. Works beautifully, few problems. Also, this lets you run the task asynchronously, so you can still return the page in N ms and then load t…

Thanks, I appreciate the link to Thrift. ... and I agree on the responsivity comment. I guess I'll look into setting up a daemon to my math in the background.