如何最好地调整图像关闭服务器 [英] How best to resize images off-server

查看:187
本文介绍了如何最好地调整图像关闭服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用户上传图片到网站。这些图像的大小以不同的尺寸。我现在做的,我的服务器上,而是在想处理的是在AWS上或类似的东西。这是一个好主意吗?

I have a site that users upload images to. Those images are resized to various dimensions. I currently do that on my server, but was thinking of processing that on AWS or something similar. Is that a good idea?

推荐答案

我一直在使用EC2以及类似任务的专用服务器,这里有一些提示:

I've been using EC2 and dedicated servers for similar tasks, and here are some tips:

  1. 使用尽可能少的IO越好。如果你打算使用像ImageMagick的,知道写入磁盘浪费IO资源(除非你想反正缓存它。)PHP / GD您可以直接在HTTP响应发送JPEG。

  1. Use as little IO as possible. If you intend on using things like ImageMagick, know that writing to disk is a waste of io resources (unless you want to cache it anyway.) PHP/GD lets you send jpeg directly in http response.

免费尽快RAM可能:释放源和调整大小的图像时,您可以。消除你的服务器换出内存的机会。

Free RAM as soon as possible: release source and resized images whenever you can. Eliminate the chance of your server swapping out memory.

EC2与上下文切换极其缓慢。因此,尝试尽可能少。像瘸子处理器是-extremely-慢(比例下降了了0.2秒上专用的,用了7秒EC2)。另外,ImageMagick的极其缓慢,期。如果可以,使用PHP / GD可为你加工的。

EC2 is extremely slow with context switches. So try as little as possible. Processors like Gimp are -extremely- slow (a scale down that took 0.2 seconds on dedicated, took 7 seconds on EC2.) Also, ImageMagick is extremely slow, period. If you can, use PHP/GD for all of your processing.

记得设置最大内存。你需要的图像的两个副本在内存中(源和缩小。)

Remember to set maximum memory. You will need two copies of the image in memory (source and scaled down.)

最后但并非最不重要的:开始与实时性。切勿启动mysql的队列和外部的守护进程矫枉过正的解决方案。这些将被证明很难在长期内保持。所以给实时试试你建立一个火箭之前。

Last but not least: start with real time. Don't start with overkill solution of mysql queues and external daemons. These will prove hard to maintain in the long run. So give real-time a try before you build a rocket.

祝你好运!

这篇关于如何最好地调整图像关闭服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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