我是否已经无法满足共享主机的需求,或者我的脚本没有优化?

发布于 2024-10-09 13:42:57 字数 300 浏览 0 评论 0原文

我目前每天的访问量超过 1000 次,托管在 1and1,PHP 内存限制为 30MB 我有一个包含 5000 多个商品的动态购物指南,用户输入浏览/搜索商品。我开始时不时地收到“内部错误 500”。哪些在几天里显示得更多,而我在其他人身上没有注意到它们。 1and1 支持人员说我已经超出了 30MB PHP 限制。 你怎么认为?这是真的吗?或者他们只是想卖给我一个更昂贵的主机?我目前只能负担得起共享主机:(

我正在使用 PHP / MySQL Javascript / 我的 BB 论坛 / PHP 缩略图(我现在尝试使用静态缩略图进行切换以减轻负载) 感谢建议

I currently have more than 1000 visits / day and hosting at 1and1 with PHP memory 30MB limit
I have a dynamic shopping guide with more than 5000 items and users enter to browse / search for items. I started getting "Internal Error 500" every now and then. Which are show more on days, and I don't notice them on others. 1and1 support say that I have outgrown the 30MB PHP limit.
What do you think? Is that true? or they just want to sell me a more expensive hosting? I currently can't afford more than a shared host :(

I am using PHP / MySQL Javascript / My BB Forum / PHP thumbail (which I am now trying to switch with static thumbnails to ease the load a bit)
Advice is appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

趁微风不噪 2024-10-16 13:42:57

磁盘空间限制不太可能导致 500 秒,即使有 5000 个超过 30mb 的项目,每个项目大约为 6k - 仅当每个项目都有图像时才可能。

当您达到磁盘配额时,大多数 PHP 框架都会自行报告错误,而不是发送标准的 500 响应,因此 30Mb 限制几乎肯定不是问题。您的托管公司可能有其他限制,但即使每天 1000 次访问也不应该突破最严格的托管阈值。您的托管公司更有可能正在寻求轻松的追加销售。

给我们一个 URL,也许我们可以得到更清晰的图片,但更有可能的是您网站的代码中出现了一些问题。当然,在没有任何参考资料的情况下,这严格来说只是一个理论。

It's very unlikely that disk space constraints are causing 500s, even with 5000 items over 30mb, that's roughly 6k per item - only probably if each item has an image.

When you reach your disk quota, most PHP frameworks will report an error themselves, rather than sending a bog standard 500 response, so the 30Mb limit is almost certainly not the problem. Your hosting company may have other limits they're imposing, but even 1000 visits a day shouldn't break the most draconian hosting thresholds. It's more likely that your hosting company are looking for an easy up-sell.

Give us a URL and maybe we can get a clearer picture, but it's more likely something is simply broken in your site's code. Of course, without any reference material, this is strictly a theory.

梦里南柯 2024-10-16 13:42:57

如果您的 PHP 内存达到 30 MB(如果您实际上正在谈论 php memory_limit 设置,看起来您就是这样),那么很可能一些优化可以解决它。如果我正在处理大型数组和/或转换为 PDF 文件等,我通常只会达到这种数字。然后我通常会找到一种方法,通过使用 memcached 或以其他方式写入 PDF 来减少数组大小像那样。

有时最简单的事情就是购买升级。使用硬件来解决问题至少可以是一个快速解决方案。如果您通过网站赚钱,那么每当您获得 500 分时,您都可能会赔钱,因此这对您来说可能是明智的财务选择。但是,你没有问这个问题。 :)

要确定您的脚本使用了多少内存,请撒上 https://www.php.net/memory_get_usage 在战略地点周围查看(假设您没有可以更好地处理此问题的分析器)。

If you are bumping up against 30 megabytes of PHP memory (if you are in fact talking about the php memory_limit setting, which it seems you are), then most likely some optimization could solve it. I usually only hit that kind of number if I'm processing large arrays and/or converting to PDF files, etc. And then I usually figure out a way to drop the array size by using memcached or writing the PDF some other way or something like that.

Sometimes the easiest thing to do is to buy their upgrade. Throwing hardware at the problem can at least be a quick fix. If you are making money from your web site, any time you get a 500, you could be losing money so it might be wise financially for you. But, you didn't ask that question. :)

To determine how much memory your scripts are using, sprinkle https://www.php.net/memory_get_usage around at strategic spots to see (assuming you don't have a profiler that can handle this better).

花开半夏魅人心 2024-10-16 13:42:57

我已经转移到另一个主机“Blue Host”,从那时起错误就停止了。看来他们以不同的方式处理资源:“CPU 节流”。他们告诉我我可以使用他们的服务,直到我觉得网站速度很慢,然后我应该切换到 VPS 或专用服务器。 1and1 处理共享限制上的过载并出现错误 500。这不好!

I have moved to another hosting "Blue Host" and the errors stopped ever since. It seems they handle the resources in a different way: "CPU throttling". And they told me I can use their services till I feel the website is slow and I then should switch to VPS or dedicated server. 1and1 handle the overload on shared limits with error 500. This is not good!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文