doulao2916
doulao2916
2011-09-27 10:35
浏览 31
已采纳

处理php和mysql的最快方法?

I am looking for any kind of way to process php & mysql faster than my MacBook Pro running XAMPP is able to do.

I have written an application, that has to process a lot of data for some simulations. On my MB, this takes about half an hour each time I want run a simulation. Not so very handy.

Is there a good (and cheap) way to process these simulations a bit faster? I already enabled MySQL-Caches and PHP eAccelerator - but it's just simply too slow. I'd love a service, where I could place some MySQL-DB, some PHP and gain a lot of processing-power.

Is there something faster than XAMPP to tun this?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyou9818
    dongyou9818 2011-09-27 10:45
    已采纳

    Generally speaking, performance is difficult to determine without going into details about your implementation so I can't really offer much advice beyond a few tips:

    As the commenters mention, PHP isn't designed for number crunching; something like Python, Java, or C++ are far better suited to this kind of task.

    Is 30 minutes a reasonable amount of time for the task to take? Assuming it takes 10 minutes less, will that actually be worth spending money on? Better planning and running jobs overnight is far cheaper :)

    As far as alternatives go you could try running your jobs on an Amazon EC2 instance, which may give you a bit of a speed boost but you'll still be running on one core; so your simulation will run roughly as quickly, ignoring input/output.

    If you actually want to optimise it, profile your application. You need to know where the time's being spent so you can figure out which parts you should spend time optimising; once you know which part of the code takes so long you should be able to try different approaches to get it working faster. Make sure you know the quirks of PHP, there are some surprising performance differences you might not be aware of. Optimisation can help, but always make sure your time spent doing it is going to be worth the time it saves.

    点赞 评论
  • douba2705
    douba2705 2011-09-27 10:42

    You could rent some processing power from a hoster.

    You should however find the source of the slowness. Analyze the points that take a lot of time. Is it disk access? Try a memory cache. Are the queries slow because they don't hit indexes for examlpe? Analyze and improve your queries. Does your code use massive loops of querying which could be done in a join? Then use a join.

    点赞 评论

相关推荐