asilvas / node-image-steam

A simple, fast, and highly customizable on-the-fly image manipulation web server built atop Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Latency at displaying an upload image the first time

jialbanc opened this issue · comments

commented

Good night, i made a service uploading images on the same folder that is used by your image steam web server to process images, after the upload is complete i make a request of that image, but it fails by
been displayed on a tag "img" as it is showed on the picture above.
This only happens when the picture is heavy and big, so it's probably a latency when your web server tries to generate the caching.
image
There is a way to force that cache generation inmediatly after uploading or another way.

I will aprecciate your help.

Howdy,

You're right that first-time requests can be much slower, as this is when we generate "optimized original" to speed up subsequent requests. But the slowness you're seeing is pretty terrible.

Things to look into:

  1. The hardware configuration (memory size, number of cores, and frequency of those cores) -- image processing can be much faster if there are many fast cores available
  2. Timeouts - While 3 seconds is very slow, the fact that you're seeing a timeout to me indicates a failure you should be logging. If I were to guess, it could be the result of an image that is too large to fit into memory uncompressed. Remember a 10MB jpeg can be consume 100-200+ MB in memory as image operations will always be performed on the uncompressed data.
  3. Sharp options - The image processor has a number of options that can be tuned to your specific hardware: https://github.com/asilvas/node-image-steam#processor-options
  4. Network - If things are slow overall it's possible you might need to look into where you're storing these files (originals and cache) to better understand the bottlenecks. Sometimes it's as simple as performing a bandwidth test between the two points. But in general I'd highly encourage using public cloud offerings such as S3 that are highly elastic and tackle scaling for you.

Before you get too far into the trial and error I'd suggest you start capturing & inspecting the logs to better understand where the timeout is coming from.

commented

Thanks for your response.
The logs shows me this error after requesting the image as you see in the image above.
image
These are the details of the image I'm trying to upload.
image
I already try changing the config options, the cpu have 4 cores. Above are my setup options:

image

image

Thanks for your help.

EISDIR indicates the location you're reading or writing to is invalid. Verify your paths. Or if you have a simple setup that I can run locally I can take a look. But it should be simple enough for you to debug.

commented

Hi @asilvas again, i would appreciate if you could take a look of my project https://github.com/jialbanc/image-test, I already debug it and couldn't find the exact line of the error. Thanks for your help

Your project works fine. You're probably trying to access root (localhost:13337/), but instead you want to access assets in your files folder. If files/image.jpg exists, you'll be able to access it via localhost:13337/image.jpg, which in turn means you can do image operations ala localhost:13337/image.jpg/:/rs=w:200