- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我无法使我的 Perl 脚本在服务器上稳定运行。问题就在这里。
当每秒访问脚本超过 5 次时,服务器会卡住。一段时间后,服务器永远挂起。SSH 没有响应,我必须重新启动服务器。
我将 Apache 与 mod_perl
结合使用。
该脚本托管在 Ubuntu 下的虚拟专用服务器上。我正在通过 SSH 操作它。这些是服务器参数中央处理器:400 兆赫内存:256MB
脚本的最长执行时间为 200 毫秒。
我已经使用“top”实用程序监控服务器负载。它没有显示任何问题,这是每秒加载 5 个脚本期间的 CPU 统计信息:
Cpu(s): 12.1%us, 0.6%sy, 0.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 87.2%st
What options do I have to make the script work without problems?
This is the result of ps aux | fgrep perl
at the moment of loading:
ps aux | fgrep perlwww-data 2925 0.3 6.5 45520 17064 ? R 17:00 0:01 /var/www/perl/loa -k startwww-data 2926 0.2 6.5 45520 17068 ? R 17:00 0:01 /var/www/perl/loa -k startwww-data 2927 0.4 6.5 45676 17060 ? R 17:00 0:01 /var/www/perl/loa -k startwww-data 2928 0.3 6.5 45676 17060 ? R 17:00 0:01 /var/www/perl/loa -k startwww-data 2929 0.2 6.5 45676 17060 ? R 17:00 0:01 /var/www/perl/loa -k startwww-data 2931 0.4 6.5 45740 17076 ? R 17:00 0:01 /var/www/perl/loa -k startroot 2968 0.0 0.2 3196 656 pts/0 R+ 17:06 0:00 fgrep perl
UPDATE
I have found the bottleneck.I've been using DateTime module many times around the code.The following DateTime module methods appear to be very slow.
I'm going to substitute them with fast analogs.
Another concern.mod_perl instance takes a lot of memory.And I have no idea why.I have tried to run a simple perl script that does not import any modules.I run it just after apache restart.The script takes 37M of memory.Why does it happen?Do you know how to force mod_perl do not use the extra memory?
A regular perl script, without mod_perl support, takes 3-5M of memory.
Guys, thank you for so much help, I wasn't expecting such a wonderful response!
UPDATE 2
I have found one more fact.I've created a simple perl script that just waits for 5 seconds.
#!/usr/bin/perl
use CGI;
my $query= new CGI;
my $content = "5 second delay...\n";
$query->header(
'-Content-type' => "text/plain",
'-Content-Length' => length($content)
);
print $content;
sleep(5);
然后我同时生成许多这些脚本。顶级实用程序中的隐身时间 (st) 从 0% 跃升至 80%,并保持在较高水平,直到脚本完成。
这个负载从哪里来?
此外,正如我已经提到的,每个 perl 实例占用 36M 内存。
最佳答案
top
中的数字似乎表明您的 VM 之外的其他进程正在限制您的 CPU,请注意最后一个数字,87.2%st,这表明大约 87%你的 CPU 时间被你的管理程序分配给你的 VM 之外的任务,即使你的 VM 有它想要运行的东西。这是否与您的问题有关很难说。
除了按照 unwind 的建议升级您的服务器之外,使用 zoul 建议的持久进程环境,您的进程可能根本不受 CPU 限制,而是受 IO 限制,例如网络或磁盘访问,或内存限制。如果没有关于您的脚本在调用时实际执行的操作的更多详细信息,则很难说清楚。
编辑:您更新的关于内存使用信息的问题很有启发性,因为您的每个进程都需要 45M 的内存,并且正在共享 17M 以上的内存。仅运行 5 或 6 个进程,您就超出了可用的 RAM 量。对于一个普通的 Perl 脚本来说,这是一个很好的内存量,它用它做什么?
关于linux - 为什么我的 mod_perl 脚本会卡住我的服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1543536/
我正在我的 xamarin.forms 应用程序中实现扫描仪功能,为此我正在使用 iOS native AVCaptureSession。但我的问题是在扫描或捕获 session 处于事件状态并且设备
所以我目前正在为我的项目制作一个音乐应用程序,它允许用户创建自己的音乐播放列表。但是,当我单击显示媒体选择器按钮时,它只显示白屏,当包含媒体选择器的 View 是 Initial View Contr
当我尝试在模拟器中启动 AVD 时,会出现一个小窗口(见图片),5 秒后它说没有响应并一直保持这种状态直到我关闭它。 我在网上搜索并尝试了所有解决方案,但都没有成功 在 BIOS 中启用了虚拟化 已安
尝试使用以下命令从视频中提取特定帧(删除了文件的特定名称!: ffmpeg -i video.mp4 -vf "select-gte(n\,6956)"-vframes 10262 文件夹/帧%d.j
我怎么知道终端正在继续工作而不中断它? 我已经运行了以下 git 命令: clone git://ligo-vcs.phys.uwm.edu/lalsuite.gituote 一段时间后它似乎被卡住了
我对 WPF 中的数据网格有一个奇怪的问题。我正在为我的应用程序使用 MVVM 模式,并且我的 View 模型实现了 idataerrorinfo 接口(interface)。每当我在添加新行后在我的
我有这个 Excel 文件,当我输入数据时它卡住了。例如,我双击一个单元格,输入数据,然后按“输入”。它会卡住而不是进入下面的细胞。按几次“enter”不会解冻程序,唯一有效的是用鼠标选择另一个单元格
我有线程池的任务队列,每个任务都有卡住锁定其正在使用的所有资源的倾向。并且除非重新启动服务,否则这些无法释放。 ThreadPool 中有没有办法知道它的线程已经被卡住?我有一个使用超时的想法(虽然我
我制作了以下小程序来确定内存是否用于 freeze(X,Goal) 之类的目标回收时 X变得无法访问: %:- use_module(library(freeze)). % Ciao Prolog n
我有一个使用 swing 的简单 java 应用程序。然而,当我执行程序时,框架将会出现,但我无法单击任何地方,并且按钮仅在几秒钟后出现。我对 javas Swing 库非常陌生,所以我可能会丢失一些
我正在尝试创建一个简单的 TCP 客户端服务器应用程序接口(interface)用户可以在按下相应按钮时启动或停止服务器我创建了一个 StartServer 按钮,当用户按下按钮时它应该连接到服务
我正在尝试从 ftp 服务器下载文件,但在检索文件时卡住了。我正在使用 commons-net-3.6.jar 我注意到的事情 当我使用 ftpClient.enterRemotePassiveMod
我正在尝试编写一个函数,该函数将能够找到位于我系统上的可执行文件搜索路径中的任意可执行文件。我遇到了一些输入会导致 SearchPathW 的问题无限期地卡住,我不确定到底发生了什么。 std::op
我的 Nativescript 应用程序的许多页面中都有 RadSideDrawer。主应用程序组件有一个 page-router-outlet并且所有其他页面都通过导航加载到此组件中。带抽屉的页面包
我有一个最小的服务器,它等待客户端连接,然后他启动一个线程,将回复发送回客户端,问题是回复。 这是服务器的代码: int port = 1234; ServerSocket servSock =
我有一个使用 C# 的 WinForms 应用程序。我尝试从文件中读取一些数据并将其插入到数据表中。虽然此操作很忙,但我的表单卡住并且我无法移动它。有谁知道我该如何解决这个问题? 最佳答案 这可能是因
在我们学校最新的项目中,我遇到了一些问题。我想观察新条目的路径,该路径是由文件导向器按钮选择的,但如果我选择任何文件,整个窗口都会卡住...我猜它被卡住,因为调用了“observePath”方法,但我
当我输入一百万作为输入数字时,我的程序卡住了。我该如何解决这个问题? 我尝试将第二个 for 循环分离为第二个函数,但没有成功。 import java.io.*; public class Arra
早上好编译我的应用程序时,我在 Android Studio 上遇到问题。我在构建时没有收到关于 app:transformClassesWithDexBuilderForDebug 的任何输出错误,
我正在使用以下触发器 DELIMITER ; CREATE TRIGGER updateCount AFTER INSERT ON user_info FOR EACH ROW BEGIN UPDA
我是一名优秀的程序员,十分优秀!