Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7691995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:45:03+00:00 2026-05-31T20:45:03+00:00

Using EC2 instances (along with Amazon Auto Scaling and Elastic Load Balancing) I have

  • 0

Using EC2 instances (along with Amazon Auto Scaling and Elastic Load Balancing) I have several instances of a TCP server running in Amazon Web Services. Each EC2 instance has access to a centralized database (running on Amazon RDS). To make this backend scalable, new EC2 instances (of the TCP server) are scaled up and down depending on demand.

The servers have been made using the Python Twisted framework. The system powers a custom instant messaging service, with multiple group chats that users can join.

When a user starts using the service they establish a TCP socket with one of the TCP servers. Each server stores in memory the currently connected users (i.e. the open TCP sockets) and which ‘group chat’ each user is currently ‘in’ (and thus subscribed to). All chat data created is stored in the database.

The Problem

When UserA posts a message in GroupChatZ, all users ‘in’ GroupChatZ should receive the message. This is simple if there is only 1 TCP server: it would search its memory for all users ‘in’ that ‘group chat’ and send them the new message. However as there is more than one server, when a new message is created it is necessary for that server to pass the message on to all the other servers (i.e. EC2 instances).

What is the most efficient solution to this problem? Perhaps using AWS components.

One solution I can think of is for each server to store its IP address in the database when it first starts up, and get the IP address of all other connected servers and set up a TCP connection with them. When each new message is received, the server handling it could send it to all other servers it is connected to.

However TCP connections are not 100% reliable and this solution adds complexity.

I suspect there is actually a good way to use some Amazon Web Services component to implement a simple subscriber-publisher type mechanism (think Observer design pattern). I.e. where one server adds something all other servers get the message from it in real-time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:45:04+00:00Added an answer on May 31, 2026 at 8:45 pm

    Not only are TCP connections not 100% reliable, EC2 instances are not either. They can disappear at any time (and believe me, they sometimes do). The internal IP address of an instance is also subject to change (e.g. if it reboots). If you use an Elastic IP address, connections from outside the AWS data center (e.g. the chat clients) will have a stable (set of) IP’s to connect to. However, using Elastic IP’s to communicate between servers is relatively slow as the connection is routed outside of the AWS firewall and then back in (last time I checked anyhow).

    Here are a few strategies to consider:

    1. Use a larger EC2 instance that can handle all of your connections, with a hot standby if your availability requirements so dictate. You may find it’s less expensive to scale up than to scale out if it can greatly simplify your Engineering efforts, if the upper bound on traffic is known (e.g. if this is an enterprise chat application rather than an internet-facing one).

    2. If you decide you still want to scale out, consider a transactional, distributed cache such as EH Cache to store the chat data. That class of problems has already been solved. You will spend a LOT of Engineering time handling all of the cases that one of the established distributed caches already handle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have several Amazon EC2 instances running and we were using the same
I have several amazon ec2 instances running Linux AMIs based on fedora and even
I have a few web servers behind an Amazon EC2 load balancer. I'm using
I have just started using Amazon EC2 API in Java. I have created instances
I have created an Amazon EC2 Instance that provides Windows Server 2008 with SQL
I have set up one of my EC2 instances with git and using a
We're using Amazon EC2, and we want to put an ELB (load balancer) to
i am using the boto python module for polling amazon ec2 instances, however it
I am using Zend Framework's library to manage EC2 instances and AMI. However I
I'm running Ubuntu on EC2 (using the alestic community AMI) and on startup my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.