用最少的资源的可能,这将是模拟挂起的Web应用程序的最佳方式? [英] Using the least resources possible, what would be the best way to simulate a hung web application?

查看:136
本文介绍了用最少的资源的可能,这将是模拟挂起的Web应用程序的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建模拟挂起/冷冻网页的页面。例如,我可以在PHP中使用很长的休眠。但是,如果我想使这个公器,我可以想像,这可能吃起来服务器资源(插槽,内存等等 - 我不认为在这个级别抽象的经历),并最终导致服务器实际问题<。 / p>

我不想只是与客户端关闭套接字,因为这将不提供的等待的行为我要模拟的类型

该解决方案不必须PHP相关。这只是一个例子。它可以是任何语言和/或网络服务器。唯一的标准是Linux开放源码软件。


解决方案

您可以简单地使用netcat来侦听端口和返回任何结果。

  NC -l本地主机8080

或者,如果你想让它继续监听,当客户端已经关闭了连接。

 而(TRUE);做NC -l本地主机8080; DONE

编辑:NC的某些版本有-k选项强制netcat的套接字被关闭后继续收听。在这种情况下,你不需要循环。

I want to create a page that simulates a hung/frozen web page. For example, I could use a really long "sleep" in PHP. But if I wanted to make this a public tool, I could well imagine this might eat up server resource (sockets, memory, etc - I'm not that experienced at this level of abstraction) and eventually cause real problems for the server.

I don't want to simply close the socket with the client, because that would not provide the type of "waiting" behavior I want to simulate.

The solution doesn't have to be PHP related. That was just an example. It can be any language and/or web server. The only criteria is FOSS on Linux.

解决方案

You can simply use netcat to listen on a port and return nothing.

nc -l localhost 8080

Or if you wanted it to continue listening when the client has closed the connection

while (TRUE); do nc -l localhost 8080; done

edit: some versions of nc have the -k option to force netcat to continue listening after the socket is closed. In those cases you don't need to loop.

这篇关于用最少的资源的可能,这将是模拟挂起的Web应用程序的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆