SoSa - The Beginning of The End

SoSa - The Beginning of The End

If you've been following my journey for SoSa (https://www.dhirubhai.net/company/sosa-community/) you'll know that i'm currently developing a social network and doing my best to document my success and failures along the way.

In itself what i'm developing from a purely functional perspective is fairly trivial, in it's simplest form:

Chat Rooms, DM's, Forums, Meetups, User Profiles, Achievements, Subscriptions and Advertising

No alt text provided for this image

You can find tutorials on how to make all of these on Youtube, but I am learning from past mistakes and so what i'm building has a few technical goals:

  • It needs to be scale-able
  • Must be able to handle thousands of concurrent users out the gate
  • Both development and financially it must be sustainable
  • I need a clear vision for the architecture so other people can contribute to the platform.
  • I'm aiming for a Facebook level - never offline architecture, with the budget of a paper boy

Development has come along really quickly, today I've hit the first major architectural design decision that will impact how it achieves these in the future and I wanted to share my thought process, see what other developers and architects thought and see if I've missed anything.

Micro service Madness

The original version of SoSa was a monolith and it made it difficult to maintain but also typically meant if something broke - it all broke.

So this rebuild is being built as a series of distributed, interconnected micro-services with a common language.

The first Micro service I have built so far is the Chat Server and i'm at the stage where I need to build the authentication and profile service to handle platform wide authentication and user profiles.

No alt text provided for this image

Things like usernames, user ids, profile pictures, profile descriptions, permissions etc but this presents an interesting problem in how I deliver data to the client when you send it a piece of information. In our case a chat room message!

Scenario 1

No alt text provided for this image

Currently, this is close to how the current set up looks, just without the Auth / Profile server (It's being mocked at the moment)

  1. Sender, sends a message to the chat server containing the message data and the room_id
  2. The Chat server processes the message and contacts the Auth / Profile server to relay information about the user back to the client
  3. The Chat Server emits the new message, containing the data it's retrieved.

Simple right?

Pros:

  • The client only needs to be aware of the chat server
  • One source of truth
  • Controlled message structure
  • Only one socket connection required

Cons

  • Difficult to maintain, structure changes will need to be done at several layers
  • Great for the first time the client has seen this sender but then it always receives the extra information, every chat message - even if it doesn't need it.
  • Not only do the two servers need to understand how each other talks, the client does as well
  • If either falls over, the servers need to handle this as well as the client

Scenario 2!

No alt text provided for this image

Scenario 2 tries to abstract the Chat and Auth server from each other, the client is aware of both, but the servers don't really need to talk.

  1. Sender, sends a message to the chat server containing the message data and the room_id
  2. The Chat server processes the message and then emits it to the end client
  3. End client speaks to the Auth server to grab any profile information it needs.

Pros

  • Client is only retrieving the information it needs
  • Auth and Chat server don't need to be aware of each other
  • If one falls over, only the client needs to know how to handle it (and will continue to work if the profile server is down)
  • Profiles can contain more or less information without changing other servers to handle that

Cons

  • Scaling between the client and end service will require much more initial outlay
  • Client must maintain socket connections to both servers
  • Software based fail-overs will be complex
  • Servers will have duplicate code for connect / disconnect failovers

This solution is looking much better but there are some client side and failover concerns that could be deal breakers, also although software issues are pushed up the stack to the client more it provides more scope for things to go wrong.

Scenario 3

No alt text provided for this image

Scenario 3 tries to combine both 1 and 2 in a way that keeps the load on the client down, allows the client to use a common language across all services including for failover, is scalable and allows each service to handle it's own redundancy.

  1. Sender, sends a message to the Socket / RabbitMQ server containing the message data and the room_id
  2. The socket server relays it to it's destination service (chat server in this situation)
  3. The Chat server processes the message and then emits it back to the socket server
  4. Socket server relays it back to the client
  5. The client can then use the same mechanism to get any profile data it needs.

Pros

  • Only one socket connection required
  • Client can speak a common language regardless of service
  • Software based failover is based on service discovery and accessibility
  • Servers don't need to be aware of each other but can communicate the same way the client can with each
  • Horizontal scaling can happen at every layer transparently
  • I can remove / add servers with different functionality for individual users easily without breaking other users experience
  • Profiles can contain more or less information without changing other servers to handle that
  • Client is only retrieving the information it needs

Cons

  • There will be a message relaying overhead for the Socket / RabbitMQ server
  • Added complexity could make some bugs more difficult to find

What do you think? Have I missed anything?



James Mahy

???? Open to work ?? Full stack ?? Building bearly.fit ?? twitch.tv/mahybe ?? @mahybe.com on Bluesky

5 年

Jon Bailey thought this one might interest you

Adrian O.

I’m just another expensive, soon-to-be-replaced-by-AI web developer with a sweet tooth for code quality.

5 年

Word of warning, James: careful when you go from monolit to Microservices. You’re trading system reliance for network reliance. If your monolith crashes, you restart it. If a microservice crashes.. set aside time to figure out why. Maybe if your monolith is hard to maintain you should make it more modular but still keep the pieces together. #mytwocents

??Lilly Spantidaki-O’Leary

Manager, Recruiting | DEI Global Program Leader | Storymaker Pro | Gamer | Crisps Connoisseur Opinions are my own

5 年

Congrats James! Keep writing about your journey!

要查看或添加评论,请登录

James Mahy的更多文章

  • Hi

    Hi

    Hi

    11 条评论
  • Building a community alone

    Building a community alone

    Most weeks I get asked why I'm only accepting Patrons / donations and won't accept technical help developing SoSa This…

    6 条评论
  • Motion In The Ocean

    Motion In The Ocean

    This is my Sprint 11 update for the SoSa rebuild! Note: This update is a week behind, if you'd like to get updates as…

  • SoSa - Sprint 10 - Refinement

    SoSa - Sprint 10 - Refinement

    I have literally no idea where the last two weeks have gone. If it weren’t for Jira, I honestly wouldn’t know I’d…

    2 条评论
  • Now In Technicolor!

    Now In Technicolor!

    Hello girls and boys! It’s me! yo friendly neighbourhood James! We’re going to do things a little differently this…

    4 条评论
  • Adventure Time - SoSa - Sprint 8

    Adventure Time - SoSa - Sprint 8

    Hello, it’s me again! James! You’re probably wondering what i’ve been working on the last two weeks. Well take my hand…

  • Corona Stole My Title - Sprint 7

    Corona Stole My Title - Sprint 7

    This is my update for my social network SoSa! Don't know what SoSa is? Check out Precursor Thank you to everyone who…

    6 条评论
  • SoSa - That's a Weird Looking Patronus - Sprint 6

    SoSa - That's a Weird Looking Patronus - Sprint 6

    LinkedIn doesn't support image captions..

  • SoSa — This Is Not the Sprint You’re Looking For

    SoSa — This Is Not the Sprint You’re Looking For

    This sprint hasn’t really been a sprint, more of a really long refinement and retrospective. When I came back from…

  • SoSa — Robot Uprising — Sprint 5

    SoSa — Robot Uprising — Sprint 5

    Original post on SoSa Previously on my descent into madness: SoSa — Precursor SoSa — The Foundations - Sprint 1 SoSa —…

    5 条评论

社区洞察

其他会员也浏览了