简体   繁体   English

建议运行多个casperjs实例的环境是什么?

[英]What is the recommended environment for running multiple casperjs instances?

I am new to casperjs and planning to use it to accurately simulate anywhere from a few dozen to low hundreds of concurrent sessions accessing a private server on a private network. 我是casperjs的新手,并计划使用它来精确模拟访问数十个到数百个并发会话的任何地方,这些会话访问专用网络上的专用服务器。 Unlike typical HTTP load generators (Apache bench, httperf, ...), my purpose is to be able to control each session programmatically (increase delay between requests, have 'smarts' built into each script) and have each session have distinct source IP addresses. 与典型的HTTP负载生成器(Apache Bench,httperf等)不同,我的目的是能够以编程方式控制每个会话(增加请求之间的延迟,在每个脚本中内置“智能”)并使每个会话具有不同的源IP地址。

My current thinking is to use OpenVZ containers (openvz.org) to create each 'virtual' client running casperjs (minimal functionality I need is following elements on the UI and taking screenshots). 我当前的想法是使用OpenVZ容器(openvz.org)创建每个运行casperjs的“虚拟”客户端(我需要的最小功能是遵循UI上的元素并拍摄屏幕截图)。 Would love to hear of anyone who has done something similar. 希望听到有人做过类似的事情。

The crux of my question is: what would the 'slimmest' environment for running casperjs be? 我的问题的症结在于:运行casperjs的“最简洁”环境是什么? I'd like to strip down the OS as much as possible to be able to scale multiple clients. 我想尽可能简化操作系统,以扩展多个客户端。 Specifically: 特别:

  • any recommended low-footprint UNIX/Linux distributions for CasperJS? 是否推荐用于CasperJS的低占用空间的UNIX / Linux发行版?
  • any specific recommendations on stripping down mainstream (CentOS, Debian, ...) distributions? 关于减少主流(CentOS,Debian等)发行版的任何具体建议?

Thank you all in advance. 谢谢大家。 I look forward to hearing your input on this specific question or similar experiences/tools for what I'm trying to achieve... 我期待听到您对这个特定问题或类似经验/工具的意见,以期达到我想要达到的目标...

Fernando 费尔南多

CasperJS is headless, eg it doesn't need X running to function. CasperJS是无头的,例如,它不需要X即可运行。 Any bare bones Linux distribution will do you well. Linux的任何发行版都可以帮到您。

any recommended low-footprint UNIX/Linux distributions for CasperJS? 是否推荐用于CasperJS的低占用空间的UNIX / Linux发行版?

Arch is very lightweight and has an easy to follow Beginners Guide . Arch非常轻巧,并且易于入门 Arch's AUR has a package for CasperJS that's pretty straightforward to setup as well. Arch的AUR有一个CasperJS软件包,它的设置非常简单 Just make sure to grab the required base-devel package ( pacman -S base-devel ) before installing from the AUR as it's needed for the Arch Build System . 只需确保在获取Arch构建系统所需的AUR进行安装之前,先获取必需的base-devel软件包( pacman -S base-devel )。

any specific recommendations on stripping down mainstream (CentOS, Debian, ...) distributions? 关于减少主流(CentOS,Debian等)发行版的任何具体建议?

Not so much stripping down, but CrunchBang is based off of the latest Debian release. 没有那么多的精简,但是CrunchBang基于最新的Debian版本。 It may be worth taking a look at. 可能值得一看。 It would be much less of a hassle to setup than Arch, and uses the same APT package manager as Debian / Ubuntu. 与Arch相比,安装起来省事得多,并且使用与Debian / Ubuntu相同的APT软件包管理器。 It installs with the lightweight OpenBox window manager, but you can remove this and X all together if you'd like. 它与轻量级的OpenBox窗口管理器一起安装,但是您可以根据需要将其与X一起删除。


With that said, even a lightweight Linux environment won't help much with the amount of memory each CasperJS instance will use. 话虽如此,即使是轻量级的Linux环境对于每个CasperJS实例将使用的内存量也无济于事。 You could probably pull off a few dozen depending on the amount of memory available, but a few hundred may not be feasible. 根据可用的内存量,您可能可以拉开几十个,但可能不可行。 It all depends on how much memory each website uses. 这完全取决于每个网站使用多少内存。 Casperjs comes with some configuration options that may help reduce memory (eg don't load images, plugins, etc), but that may defeat the purpose of your tests. Casperjs附带了一些配置选项这些选项可能有助于减少内存(例如,不加载图像,插件等),但可能无法达到测试目的。

The best advice I can give is to try it out for yourself. 我能给的最好的建议是自己尝试一下。 Write a simple script that will open the pages you are going to use and pass a callback to CasperJS's run() function to keep it alive (eg don't exit from Casper). 编写一个简单的脚本,该脚本将打开您要使用的页面,并将回调传递给CasperJS的run()函数以使其保持活动状态(例如,不要从Casper退出)。 It can be as simple as: 它可以很简单:

casper.start('http://example.com/site1', function () {});
casper.thenOpen('http://example.com/site2', function () {});
casper.run(function() { 
    // wait 60 seconds before exit . . . or remove to never exit
    setTimeout(function() { casper.exit(); }, 60000); 
} 

Spin up multiple instances, and watch your total memory usage. 启动多个实例,并观察您的总内存使用情况。 You can use the cli tools top , or use this alias that totals the amount of memory usage for the current user. 您可以使用cli工具top ,或使用该别名总计当前用户的内存使用量。

alias memu="ps -u $(whoami) -o pid,rss,command | awk '{print \$0}{sum+=\$2} END {print \"Total\", sum/1024, \"MB\"}'"

From this you should be able to see roughly how much memory each instance takes, and how many you can run at once on one machine. 由此,您应该能够大致看到每个实例占用多少内存,以及在一台计算机上一次可以运行多少内存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Linux中运行多个megasync实例 - Running Multiple Instances of megasync in Linux Linux 应用程序的一个实例开始运行自身的多个实例的可能原因是什么? - What are the possible reasons why an instance of an Linux application would start running multiple instances of itself? 同时运行的多个Python实例限制为35个 - Multiple instances of Python running simultaneously limited to 35 一个内核上运行的进程的多个实例 - Multiple instances of a process running on single core Linux Shell在运行一个应用程序的多个实例时挂起 - Linux shell hangs on running multiple instances of an application 运行同一脚本 NodeJS 的多个实例 - 子进程 - Running multiple instances of the same script NodeJS - Child Processes 如何设置在不同端口上运行的多个memcached实例? - How do I setup multiple memcached instances running on different ports? 同时运行一个jar的多个实例:内存问题 - Running multiple instances of a jar at the same time: memory issue 是否建议在没有反向代理的情况下在 Linux 上运行 Kestrel? - Is running Kestrel on Linux without a reverse proxy recommended? 当运行多个应用实例而不是一个实例时,为什么Java App占用的总CPU更少? - Why does Java App take less overall CPU when running multiple instances of app instead of one instance?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM