Skip to content

Deploying laravel filament in AWS EKS with 3 or mode replicas

0

Hi,

I have a laravel filament admin panel which is dockerized and deployed to AWS EKS. I'm running 3 replicas which are backed by ALB.

After logged-into the panel and when I export data from admin panel, it gives a download button which then generates a signed URL for the user to download the xlsx. When I click the download button(signed url) it redirects to a new tab which then downloads the data.

ISSUE: The new tab shows 404 error and when we refresh after sometime the download works. I have also enabled stickiness in the ALB level. But it still not resolved.

The download works perfect with one replica in same setup. I wanted to understand is this a session issue or a data affinity issue. How to debug the situation.

1 Answer
0

This issue appears to be related to session state and load balancing in your multi-replica EKS deployment. When you have multiple replicas running Laravel Filament, the signed URL generation and subsequent download request may be handled by different pods, causing the 404 error.

Even though you've enabled stickiness at the ALB level, there are a few potential issues:

  1. Stickiness limitations: ALB stickiness takes precedence over weighted routing, but it doesn't automatically redirect traffic when a target becomes unavailable. If the pod that generated the signed URL is different from the one handling the download request, this can cause the 404 error.

  2. Session storage: Laravel's default session storage is file-based, which isn't shared between pods. When running multiple replicas, each pod has its own session storage, so session data (including information about generated signed URLs) isn't available across all pods.

To resolve this issue, consider these approaches:

  • Use a shared session driver: Configure Laravel to use Redis or database sessions instead of file sessions to ensure session data is shared across all pods.

  • Implement a centralized storage for temporary files: Store the generated export files in a shared location like Amazon S3 instead of local storage.

  • Adjust stickiness settings: You could reduce the stickiness duration to a shorter period, though this might not fully resolve the issue.

  • Implement application-level handling: Modify your application to handle connection failures or implement a retry mechanism.

The fact that it works with a single replica but fails with multiple replicas strongly suggests this is a session state or file storage issue rather than a network connectivity problem.
Sources
ALB to automatically redirect traffic | AWS re:Post

answered 9 months ago

  • The SESSION_DRIVER=database in the Laravel application.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.