dsoy71058 2012-05-14 11:04
浏览 42
已采纳

良好的服务器设置,可根据n个功能处理500个用户之间的交叉引用

Working on a tiny script that references data between users. Each user has a certain count for a "feature". For instance, feature A is (sad,happy,angry) and feature B is (sunny,clouded,thunder). The current row count of these features altogether is 200.000 for 1000 users. The algorithm is simple: for each users, count the features, calculate per feature which entry is the highest (A -> sad, B -> thunder) and make that a percentage of the total count of features per user. What I got now is a "rating" for a user, which I compare to all the users in the database (yes, by doing that all over again). Based on the assumption that highest feature + highest feature + highest feature etc. for all users, compared with all users, gives some sort of relative similarity between users.

The thing is, I'm doing this with PHP on a 4-core Xen instance from Linode. It's not very fast. Currently maxing out one core, the other for 30% and the rest sits idle. The script can be optimized, but I really want to figure out how to make the setup so that it goes faster. What kind of architecture do I need for this?

I can see that is a very broad question, but I hope someone can give me some pointers. Any help is greatly appreciated!

Kind regards,

Reinder

  • 写回答

1条回答 默认 最新

  • duanmie9741 2012-12-18 08:33
    关注

    I found out that the culprit was mysqli->fetch_assoc(), waiting for the harddisk to provide PHP with additional resources. I made the process faster by fetching all the results from the database in one go, and then processing them, instead of a one-by-one fetch-process mechanism.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable