bash 创建一个 shell 脚本,它可以产生多个调用指定 Web 服务的并发进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13014490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 03:36:46  来源:igfitidea点击:

Creating a shell script which can spawn multiple concurrent processes which call a specified web service

bashshellsh

提问by user1588220

I am trying to create a load testing shell script essentially what I am looking to do is have the script spawn some N number of concurrent processes and have each of those processes call a specified URL and perform a few basic actions. I am having a hard time figuring this out - any help would be awesome!!

我正在尝试创建一个负载测试 shell 脚本,基本上我想要做的是让脚本产生一些 N 个并发进程,并让每个进程调用指定的 URL 并执行一些基本操作。我很难弄清楚这一点 - 任何帮助都会很棒!!

回答by marstone

have a look at this article:

看看这篇文章:

http://prll.sourceforge.net/shell_parallel.html

http://prll.sourceforge.net/shell_parallel.html

as described: "Parallel batch processing in the shell

如所述:“外壳中的并行批处理

How to process a large batch job using several concurrent processes in bash or zsh

如何在 bash 或 zsh 中使用多个并发进程处理大批量作业

This article describes three methods of parallel execution: the first is not very performant and the other two are not safe to use. A more complete solution is called prll and can be found here. This article is not meant to be good advice, but instead laments the state of scriptable job control in shells."

本文介绍了并行执行的三种方法:第一种性能不是很好,另外两种使用起来并不安全。更完整的解决方案称为 prll,可在此处找到。这篇文章并不是很好的建议,而是对 shell 中可编写脚本的作业控制的状态表示遗憾。”

回答by messivanio

If you really need to use shell, take a look at Bash: parallel processes. But there are load testing tools like ab (Apache HTTP server benchmarking)that can do the job for you.

如果您确实需要使用 shell,请查看Bash: parallel processes。但是有一些负载测试工具,如ab(Apache HTTP 服务器基准测试)可以为您完成这项工作。

You can use abas simple as:

您可以像这样简单地使用ab

ab -n 10 -c 2 -A myuser:mypassword http://localhost:8080/

For more examples, look at Howto: Performance Benchmarks a Webserver.

有关更多示例,请查看Howto: Performance Benchmarks a Webserver