WordPress takes too long to show 404 error on images (on LEMP stack)

While it is impossible to pinpoint why it takes so long without access to your server, the core issue is that when the webserver do not find a file it will execute wordpress to handle the URL, and as the URL is unlikely to match any content it will result in a generation of a 404 wordpress page which is obviously much slower than returning 404 at server level.

Usually it is not a problem as pages generated by wordpress rarely contain images which do not exist, but if this is an actual problem you can adjust you webserver config (.htaccess for apach) to not propagate unresolved image urls to wordpress.