应用程序分析:内存使用 [英] Application Profiling: Memory Usage

查看:125
本文介绍了应用程序分析:内存使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经打开Codeigniter配置文件(非常有用),我注意到我的一个页面显示的内存使用:


2,405,496字节


这是〜2MB,它是一个请求 - 是否意味着如果1000个用户同时访问此页面,内存使用量将是2GB?



我有我的数学错误或有更多的,而不是只是乘以两个数字?



感谢所有人的任何帮助



EDIT



这种内存使用是正常的脚本运行2个简单的选择查询?我自动加载帮助器,如form,url以及数据库和会话类。

解决方案

2MB不是那么多 - 至少看起来很奇怪我;我经常看到更高的值,当使用一个框架,即使没有做大量的SQL查询。



注意 memory_limit ,它定义了多少内存一个PHP脚本可以使用,如果经常设置为至少8MB - 并且经常16或甚至32 MB。





1,000个用户同一时间?



首先,你确定你的应用程序会成功,足以让一千个用户同时请求一个页面吗?

请注意,如果您需要1秒钟生成一个页面(已经有点长了),这意味着有一千个用户在一秒钟内请求一个页面!



然后,无论如何,你的服务器可能永远不会支持那个负载 - 默认情况下,我应该补充说,Apache通常被配置为不服务多于200并发请求。 / p>

如果你真的期望在同一时刻有1000个用户在你的应用程序,你会有很多其他问题,我会说 - 必须优化很多,和/或使用多个服务器。


I have switched on the Codeigniter profile (very useful) and I have noticed that a page of mine shows the memory used as:

2,405,496 bytes

That's ~2MB and it's for one request - does it mean if 1000 users accessed this page at the same time, memory usage will be 2GB?

Have I got my maths wrong or is there more to this than just multiplying two numbers?

Thanks all for any help

EDIT

Is this sort of memory usage normal for a script running 2 simple select queries? I do autoload helpers such as form, url and also Database and session classes.

解决方案

2MB is not that much -- it doesn't look surprising to me, at least ; I often see much higher values, when using a framework, even if not doing lots of SQL queries.

Note that the memory_limit, which defines how much memory a PHP script can use, if often set to at least 8MB -- and quite often 16 or even 32 MB.


1,000 users at the same time ?

First of all, are you sure your application will be successful enough to have one thousand users requesting a page at the same time ?
Note that if you need need 1 second to generate a page (which is already a bit long), it means having 1,000 users requesting a page in that one second !

Then, anyway, your server will probably never support that load -- by default, I should add that Apache is generally configured to not serve more than something like 200 concurrent requests.

If you really expect to have 1,000 users at the same instant on your applicatio, you'll have plenty of other problems, I'd say -- and you'll probably have to optimise a lot, and/or use more than one server.

这篇关于应用程序分析:内存使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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