arao6
arao6

Reputation: 3376

Static variables and Amazon AWS

I've been migrating my application to Amazon's web services, and one thing that confuses me is what happens to my static variables? Do they persist across instances (and if not, how do I persist them)?

Upvotes: 1

Views: 392

Answers (1)

Josh Davis
Josh Davis

Reputation: 6831

No, static variables in your applications that run on multiple EC2 instances do not persist across instances.

Your two options will either be a database, such as RDS or Dynamo, or an in-memory solution that supports same region replication like ElastiCache.

When thinking of the cloud, the important thing to remember when dealing with an application that can scale is volatility. Instead of having a single server that lives for the entire duration of the application, it is more useful to think of instances as that can be killed off and spawned at any time. Thus relying on in memory state is very dangerous.

Upvotes: 1

Related Questions