Latency problem with raster calcul

I need to create a proximity raster based on 2 others rasters that i import in my application through an S3 bucket. When i have this proximity raster i need to be able to display it on a map.
My problem is the calculation time which is too long and also hos to display the raster whitout saving it.

There are two ways of improving that:

  • Better algorithms.
  • Better hardware.

What kind of python object is the raster that you have?

I am working with numpy array before saving it to tiff file

st.image can display numpy arrays.