Seeing a strange behavior with <cfimage> and...
# cfml-general
m
Seeing a strange behavior with <cfimage> and a load balanced site.
It's load balanced through CloudFlare with two CF servers. On one of the pages, there is a <cfimage> with "writeToBrowser". It's putting from a non-web accessible file share and displaying the image on a form. When I go to either server independently, everything works as expected. When I go through the load balancer, it mostly always works. But there are sporadic 404 on the rendered _cfimg. I'm not 100% sure where to go to troubleshoot this. Nothing obvious in the CF or IIS logs.
Individual servers one and two, both fine
image.png
Through CloudFlare on the LB
Same image in all three requests.
Any thoughts as to where to track this down and better troubleshoot?
Also, when I turn off either of the origin at CloudFlare so that it's still going through the load balancer, but essentially just going to one server ... the issue goes away too.
d
Images generated dynamically have a short shelf live. CF will purge the files, which most likely explains why trying to refresh the image is returning 404s.
m
Roger that. The 404s are all in the same request. Identical requests on individuals servers are coming back 200s, but through the LB, 400s
f
The /CFFileServlet writes the image to disk temporarily, so the actual file will only be on one of the two servers
m
Is it a second http request for <cfimage>?
f
I think it might be, take a look at the Response tab on the cfm that has the cfimage tag in developer tools
m
As I'm typing that out, I realize what you both are saying and get it. Of course, it's a separate http request for the <img>. And obviously, that could be on the other local drive
<cfimage> with writeToBrowser won't ever really work consistently in a LB unless you have something like sticky sessions enabled.
f
you might need to write to a temp file, then serve it yourself with cfcontent - that should work fine in a LB env
I think cfimage writeToBrowser is either just outputting an HTML <img> tag or redirecting to the /CFFileServlet either way it is causing a second http request
m
That's exactly what I'll do. Thank you for the sanity check.
👍 2