craft3-beam icon indicating copy to clipboard operation
craft3-beam copied to clipboard

Document load-balanced environment configuration for temporary file storage

Open Copilot opened this issue 1 month ago • 4 comments

Temporary export files stored on local filesystem cause intermittent failures on load-balanced deployments when subsequent requests hit different servers.

Changes

  • Documentation: Added concise "Load-balanced environments" section to README
    • Explains the problem briefly
    • Documents using Craft's tempAssetUploadFs config setting to use shared filesystem
    • Mentions CRAFT_TEMP_ASSET_UPLOAD_FS environment variable as an alternative
    • Links to Craft CMS official documentation

Solution

Instead of plugin-specific code changes, this uses Craft CMS's built-in configuration options for handling temporary files in multi-server environments.

Configure in config/general.php:

return [
    '*' => [
        'tempAssetUploadFs' => 's3', // use your filesystem handle
    ],
];

Or use the CRAFT_TEMP_ASSET_UPLOAD_FS environment variable.

This approach leverages Craft's native filesystem abstraction without requiring plugin modifications.

Original prompt

This section details on the original issue you should resolve

<issue_title>Issue with load balancer</issue_title> <issue_description>We host our site on Fortrabbit that uses a load balancer - When we try to export a excel file half the time we get an error.

fopen(/srv/app/astro/htdocs/storage/runtime/temp/beam/iogpcmrkagcn-report-2023-03-23.xlsx): Failed to open stream: No such file or directory

However if we refresh the browser then it will download.

Can it be possible to specify the location of where this file is temporarily stored? i.e. can we switch it to AWS s3 so that we can avoid the load balancer entirely?</issue_description>

<agent_instructions>Come up with a good way to approach this. Research how Craft recommends you to deal with sites on load balancers.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@sjelfull This is a good idea for future enhancement.

As always, happy to do paid consulting if you are interested in fast tracking this change.</comment_new> <comment_new>@sjelfull

I will look into how I can best support this, as I see more and more people using services like Servd, the upcoming Craft Cloud and similar.</comment_new>
  • Fixes sjelfull/craft3-beam#17

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Jan 06 '26 09:01 Copilot