面向内存的进程和面向CPU的进程的分离

我是一个电子商务公司的开发人员,我正在运行我的电子商务应用程序使用ruby on rails spree commerce构build。 我目前在生产中运行2个中等实例。 一个是高内存实例,有3.8内存和单核CPU,另一个是高CPU实例,有双核CPU。 基本上AWS调用它分别有m1.medium和c1.medium实例。 我的问题是有可能根据cpu激烈和记忆强度来分离进程吗? 这样所有的CPU激烈的过程都可以在高CPU实例中运行,并且所有的内存激烈的过程都可以在高内存实例中运行。 是否有任何工具可用于识别这些过程。 请给我点头。 谢谢

将这些东西分开是非常罕见的,通常一个CPU密集型任务在同一个盒子上完全可以完美地完成内存繁重的任务。 我想大多数情况下,使用AWS的公司都可能构build最统一的负载设备,因为您需要使用相对同类的硬件(less数特殊情况(db服务器))。 我宁愿试图找出哪个是最便宜的实例,你可以运行你至less2次(但build议3)。 通过这种方式,您可以获得更多的可用性和更less的性能开销。 您需要的工具是Linux上的ps(以及其他一些操作系统)。

中央处理器:

ps -eo 'pcpu,%cpu,pid,comm' | grep -v '%CPU PID COMMAND' | sort -n 

MEM:

 ps -eo 'rss,%mem,pcpu,%cpu,pid,comm' | grep -v '%CPU PID COMMAND' | sort -n 

请参阅手册页的字段以了解更多信息:

  CODE HEADER DESCRIPTION %cpu %CPU cpu utilization of the process in "##.#" format. Currently, it is the CPU time used divided by the time the process has been running (cputime/realtime ratio), expressed as a percentage. It will not add up to 100% unless you are lucky. (alias pcpu). %mem %MEM ratio of the process's resident set size to the physical memory on the machine, expressed as a percentage. (alias pmem). args COMMAND command with all its arguments as a string. Modifications to the arguments may be shown. The output in this column may contain spaces. A process marked <defunct> is partly dead, waiting to be fully destroyed by its parent. Sometimes the process args will be unavailable; when this happens, ps will instead print the executable name in brackets. (alias cmd, command). See also the comm format keyword, the -f option, and the c option. When specified last, this column will extend to the edge of the display. If ps can not determine display width, as when output is redirected (piped) into a file or another command, the output width is undefined (it may be 80, unlimited, determined by the TERM variable, and so on). The COLUMNS environment variable or --cols option may be used to exactly determine the width in this case. The w or -w option may be also be used to adjust width. blocked BLOCKED mask of the blocked signals, see signal(7). According to the width of the field, a 32 or 64-bit mask in hexadecimal format is displayed. (alias sig_block, sigmask). bsdstart START time the command started. If the process was started less than 24 hours ago, the output format is " HH:MM", else it is "Mmm dd" (where Mmm is the three letters of the month). See also lstart, start, start_time, and stime.