Search code examples
javascriptnode.jsgcloudimage-resizingsharp

Which is more common (or better) for handling multiple size for an image in heavy usage app?


For heavy usage mobile Node.JS app and require multiple size for an image display, should I save one copy for an image and resize every time for each specific size request (only 2,3 type), or save all different types of size of an image to google cloud? Is it cost a lot more for the latter, and if I use the former solution, would it be dramatically slower? (I'm using sharp nodejs library for resize image)


Solution

  • It is better to save multiple photos at once. Of course with a detailed calculation on the required sizes.

    As you mentioned, it's a heavy program with a lot of requests. So you need to put in your hardware resources to respond to the sent requests. Not to lock CPU to process photos. In the meantime, when you have a lot of storage space for a photo, you can hold multiple images at average and deliver the image at the desired size and have the client fix it accurately.

    By the way, you provide the client with the lowest cost photos. Since the primary task of the server is to handle the requests sent with the least amount of time and cost, you should not block CPUs.

    Also take a look at the Sharp Module benchmarks