dongzhi1822 2009-11-27 17:44
浏览 24
已采纳

当依赖于重读/写时,在php / mysql / ajax中要避免什么

i was wondering what the main things were to avoid when creating an webapplication that relies on heavy reads and writes every second.

Think of online gaming where money is involved.

For example you have an javascript that constantly updates the browser(1), There is a cronjob running that updates the db(2), There is user input submitted via ajax or POST(3), and you have multiple users performing all these actions every second(4).

There is also money involved so all the data has to be read and written the correct way(5). And in case of crashes this the data has to be restored the right way so backups(6) are important.

So many things to keep in mind when creating such a complex application, what are the things you should definitely keep in mind.

I would like to know what your opinion on this is, Thank you!

  • 写回答

4条回答 默认 最新

  • dongzhi4073 2009-11-27 18:05
    关注

    If bandwidth is an issue consider gzipping your output to the browsers. Or if CPU power is an issue and gzip is enabled, disable it but risk increased bandwidth usage.

    Set your static files such as css and images and javascript etc to cache on the browser and set to expire after a long time. This means repeat users wont use up your bandwidth etc to request the same version of a file they already have.

    Run benchmarks on querys that you use. Optimise where ever possible. Maybe splitting up long queries into smaller ones could have a performance boost. Use a profiler like xdebug to find out your bottlenecks.

    Use persistent sql connections to save resources on new connections on every load.

    Create a mirror database and when ever you insert into your main database, insert the same data into the second one. Dont read from the second database as it serves as a backup. Try having the second database on a different server if you can. If a second database is not feasable, cron job backups like you mentioned should work well.

    Next thing... is ajax really nessasary in your application? Will it work without it? Dont add unessasary bloat to your site with extra requests within ajax.

    I cant write more as i dont know the specifics of your site / app.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法