doujiao4705 2018-08-03 10:41
浏览 65

将多个文件放在后台作业或单个文件中会更好吗?

Few months ago i asked this about the implementation of my api for processing files it uses PHP, a command line script that is called via PHP and queue. For the queue i am using beanstalkd

The API accepts one file or group of files (up to 5) per request. Processing one file takes 1-3 seconds depending of the size.

My question now is whatever will be better, to put every file of the request to a separate job or all the files in one job? My function for processing that is slow accepts one or multiple files. My guess is that i put the all the files of the request on processing, they will be processed by one worker. But if i put every file into separate background job it will be probably processed by own worker so 4 files 4 workers - that is what i think. Not sure if this is correct.

So if my above conclusion is correct, is it better for a lot of requests to process all files in once or add them separate worker?

Thank you.

  • 写回答

1条回答 默认 最新

  • donglu8549 2018-08-07 19:49
    关注

    To handle more users, or more throughput in the same second you need to ensure multiple things:

    • have more than 1 worker, usually scale up the size of the worker to 10 from start
    • this way you have 10 parallel workers
    • put 10 different messages into the queue so each worker pickup a job to tackle
    • monitor queue and if more jobs keep accumulating add more workers
    • monitor machine CPU and Ram state and if starts to throttle around 80% of CPU you should consider adding another machine that consumes jobs from the same queue
    • you could have different machines for different needs (SSD for fast IO, high end CPU for quick jobs, lower machines for transactional states etc..)
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法