可扩展的异步图像调整大小

发布于 2024-11-26 16:26:36 字数 418 浏览 0 评论 0原文

我正在考虑在 PHP (CodeIgniter) Web 应用程序中处理图像大小调整的最具可扩展性的方法的一些选项。我需要将图像调整为多种尺寸,然后将它们推送到 Amazon S3。以下是我到目前为止提出的选项:

  1. 上传文件时将其添加到队列中。有一个后台 PHP 或 Python(显然 PHP 不适合长时间运行的进程)程序不断运行,它查看并处理队列,然后休眠 x 秒。

  2. 当文件上传时,会生成一个新的 PHP 进程,该进程会处理该图像,然后终止。

  3. 使用第三方服务,例如lightspun(他们目前不接受客户。还有其他服务吗?类似的服务?)

也许有。我没有考虑过更好的选择?

I'm considering a few options for the most scalable way of handling image resizing in a PHP (CodeIgniter) Web App. I need to resize an image into several sizes and then push them to Amazon S3. So here are the options I've come up with so far:

  1. When file is uploaded add it to a queue. Have a background PHP or Python (Apparently PHP is bad for long running processes) program constantly running which looks at and processes the queue then sleeps for x seconds.

  2. When file is uploaded spawn a new PHP process which processes that image then dies.

  3. Use a third party service like lightspun (They're not accepting customers at the moment. Are there other similar services?)

Perhaps there is a better option I haven't considered?

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

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

发布评论

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

评论(2

无可置疑 2024-12-03 16:26:36

我会选择你的第一选择,因为它会更可靠,并且意味着你可以在后端完成工作而无需关闭前端。

它还可以更优雅地扩展,因为如果队列变得极端,您可以将其移至另一台服务器。

I'd go for your first choice, as it would be more reliable and means you could do work on the backend without taking the front end down.

It would also scale much more gracefully, as you could move it off to another server if the queue becomes extreme.

丑丑阿 2024-12-03 16:26:36

由于已经陈述的原因,您的第一个想法听起来不错,可以减轻用户的处理时间负担,并且您可以添加更多图像尺寸等,而不会损害用户体验。我使用命令行图像 magick 工具进行图像处理取得了良好的结果,并且已经有了一些在长时间运行的进程中使用 php 并利用它的 fork 能力是很幸运的。 http://php.net/manual/en/function.pcntl-fork.php

your first idea sounds good for reasons already stated, takes burden of processing time off of the user and you can add more image sizes etc without hurting user experience.i have had good results using command line image magick tools for image processing and have had some luck using php in long running processes using its fork abilty. http://php.net/manual/en/function.pcntl-fork.php

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