ogallagher / tejos_textiles

An online arts journal for publishing works in a new medium
MIT License
1 stars 0 forks source link

Shared EFS between server instances #34

Closed ogallagher closed 4 years ago

ogallagher commented 4 years ago

Looking into the persistence of an https connection, it seems that a connection between a server and a client should remain established through keep-alive messages that are sent from the client. However, I see it highly probable that at some point during a site visit a client temporarily loses connection and the https session closes, which, when reopened, could connect that client to a different server instance.

This introduces a new problem if I scale up to multiple instances because now a user’s session could suddenly disappear from the server if the server that client was connected to suddenly gets swapped with another by the ALB (app load balancer). A way around this issue is to use a shared Elastic File System (EFS), which all instances can share, and in which sessions can be stored.

An alternative would be to just handle the possibility that sessions disappear and require that the client intermittently log in again, but this seems like a worse solution. Plus, the extra cost of an EFS could be mitigated by limiting the number of sessions stored, in addition to their expiration dates.

ogallagher commented 4 years ago

The typical pricing plan as explained here for EFS is $0.08/GB-month, or $0.96/GB/yr, which seems a great rate. If it’s just for sessions, I probably wouldn’t even need a full gigabyte, so this is definitely the plan.

ogallagher commented 4 years ago

The EFS was created and successfully mounted to the current instance, and connected to the session server.