douzhi0107 2014-11-22 21:18
浏览 50

对单个PHP脚本进行多次AJAX调用,分成工作负载=服务器端多线程?

I want to implement an algorithm that requires a lot of independent calculations using JavaScript for drawing the results (using Canvas) and PHP to do the calculations on the server. So my idea is to create a PHP script for handling a fracture of those calculations and call it multiple times using AJAX. Each call calculating a portion of the algorithm's current iteration step.

Does this result in multithreading on the server in the way that i.e. I make 100 AJAX calls to the script they will be handled simultaneously on the server as soon as they arrive?

Do you have any ideas how I can synchronize this in JavaScript? I need to make sure each AJAX call finishes before entering the next iteration step. Is there something like a best practice for that?

Thanks a lot!

  • 写回答

1条回答 默认 最新

  • doukun5339 2014-11-22 21:39
    关注

    Generally in a case where we are sure to receive continuos data from server, we maintain the http connection state so that the server can directly push data to the client without the need for client to poll continuously.

    This can be achieved using web sockets. Ratchet is a good library for php.

    In a case where you absolutely have to use the polling approach, you can have the success function of each AJAX call to make the next AJAX call.

    评论

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛