Re:Moving from PHP to C saved my web startup.
by sedachv on Friday October 22, 2010 @04:50PM
(#1821448)
So instead of understanding the problem and implementing the simplest possible solution, you're recommending throwing more middleware caching crap at it? Brilliant engineering. I think I understand "web scale" now.
Re:Moving from PHP to C saved my web startup.
by wanderr on Saturday October 23, 2010 @12:03AM
(#1822588)
How is placing the blame on the wrong tool understanding the problem?
Re:Moving from PHP to C saved my web startup.
by sedachv on Saturday October 23, 2010 @08:02PM
(#1824718)
You're right, I should have read the OP more carefully.
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @01:37PM
(#1820584)
On the frontend I was already using lighttpd, but I could have used memcached on the backend that was going to be the next step if the c app didn't work. It just worked so well I didn't have to worry about it.
Re:Moving from PHP to C saved my web startup.
by dugmartin on Friday October 22, 2010 @01:47PM
(#1820631)
I didn't mean to poop on your parade. I love writing servers too but if you have a public facing HTTP server there are a ton of obscure edge cases to worry, like some script kiddy DOSing your server by either opening a connection and keeping it open without sending anything or dribbling out a character a minute to circumvent your SIGALRM handler.
I'd think about switching back to a public interface that has been through these battles before. You could always keep your server up and use Nginx or HAProxy to front it for you and just pass the requests on.
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @01:53PM
(#1820661)
Yeah I have run into some of those problems already. Thanks for pointing that out. You definately need a SIGALRM handler if you are thinking of doing something like this. But I don't really see how switching to Memcached is going to prevent a DOS attack. Not trying to be defensive, just really wondering if there is something I'm not getting about that.
Re:Moving from PHP to C saved my web startup.
by dugmartin on Friday October 22, 2010 @02:03PM
(#1820707)
I'm not trying to be offensive either :) I was just warning that putting up a public facing server is eventually going to make you a target. Using a battle tested server will let you concentrate on getting more people to use your app instead of fighting bored 13 year olds trying to bring your server down.
Good luck with your app!
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @02:13PM
(#1820757)
Thanks! I understand your point, but a fork server is so simple I don't think there is much that can go wrong there, if it was serving more data I would be worried, but its meant to do a quick and short reply.
Re:Moving from PHP to C saved my web startup.
by konad on Friday October 22, 2010 @04:04PM
(#1821261)
it's not called a forkbomb for nothing
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @04:54PM
(#1821467)
http://en.wikipedia.org/wiki/Fork_bomb
Fork Bombs are easier to pull off from the command line. Not so much with DOS. I would say that loading a large webserver for each request would use up more resources than a tiny C program. Thats the whole point of the post.
Re:Moving from PHP to C saved my web startup.
by konad on Friday October 22, 2010 @06:09PM
(#1821726)
You're right about the webserver being overload. Threads would be less expensive than processes.
I would use Go for this service myself. Defending against abuse is hard whichever way one goes.
Re:Moving from PHP to C saved my web startup.
by rubashov on Friday October 22, 2010 @04:49PM
(#1821442)
Writing your own server in C seems a little crazy anymore. Just use a C++ framework like POCO or ASIO. POCO gives you a fast httpserver component with all the tricky stuff figured out.
Re:Moving from PHP to C saved my web startup.
by bobf on Friday October 22, 2010 @04:30PM
(#1821381)
I couldn't agree more. Nginx and HAProxy will seem like miracle workers after seeing Apache's performance.
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @01:42PM
(#1820607)
Also because of the need for consistency and latency I'm not sure memcached would be a benefit because it could never be scaled anything but vertically anyways.
Re:Moving from PHP to C saved my web startup.
by rarestblog on Friday October 22, 2010 @02:42PM
(#1820898)
Memcached? Only vertically? Horizontal scaling is built-in in all memcached clients.
Re:Moving from PHP to C saved my web startup.
by BuckToBid on Friday October 22, 2010 @02:45PM
(#1820916)
yes, I was just saying that we can't wait for replication, when someone places a bid all the others users must have that information immediately.
Re:Moving from PHP to C saved my web startup.
by rarestblog on Friday October 22, 2010 @02:56PM
(#1820966)
memcached doesn't do replication as far as I know. It will just have to do some requests second time. It still beats re-calculation on each request.
Replication is the wrong word for it. Key distribution is what you want. If a given memcache server goes down then the keys it was storing should get reloaded to a different one in your pool by your cold cache loading code.
Here are some links:
http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-b...
http://lserinol.blogspot.com/2009/03/speeding-up-your-nginx-...