A few high level app architecture questions

I’m working on app which, at the moment, contains a few separate parts:

  • A desktop chat app built with Electron.js (think Slack).
  • A simple node.js server that the desktop app communicates with. The desktop app uses socket.io to send messages to this server, which in turn emits the message to all connected clients.
  • A newly created Meteor.js app, which at the moment is acting as the download page for the desktop app, and a few other functions (like payments).

I have a few questions:

  1. I’m thinking about scrapping the node.js app and implementing its socket.io functionality into the Meteor app. Some concerns include scalability. Will having a single Meteor.js app serve the web pages and receiving a bunch of socket.io messages cause scale issues? Is it better to keep my current architecture with a seperate node.js app for the chat system?

  2. I need to implement user authentication in the Electron app so users can log in. If I decide to scrap the node.js app as mentioned above and just use the Meteor.js app, how can I connect Meteor’s default user system to the Electron app to allow users to login?

50 views no comments? :confused:

If I need to restate the question in a better way or something let me know.

I myself don’t have much experience in the problem you stating but I’m sure some people here do. If you allow me to suggest shortening and narrowing down your problem statement to a specific technical question which seems to revolve around the point below then you might have a better luck :slight_smile:

Let’s start with few questions that can lead us to better answer.

  1. Ultimately, how many users are supposed to use this app. Is that for internal use among some company workers? How many chatrooms are planned? I know you consider scaling, but this would still be useful to be addressed.

  2. Will the messages ever be saved to the database,or only passed further to all available clients at the moment? Will users or admins have some access to chat history, will there be some way to mark messages as unappropriate (spam, abuse, other potentially unwanted stuff).

That said, by default, Meteor’s pub/sub system is not the best option for large scale chatting applications. This may be better done with some simple system like Socket.io or Deepstream, unless you use some customized system to send messages with Meteor, f.e. as streams. New Redis Oplog comes pretty handy with that, but as it’s quite new, there’s not enough data yet to prove it at large scale.

If your main reason to choose Meteor is because of the authentication system available out of the box, I’d reconsider it. The authentication in Meteor is awesome, I admit, but that shouldn’t be your main worry.

1 Like

Thank’s, i’ve condensed it a fair amount, hopefully that helps.

Oh, in the meanwhile you rewrote the question. So I’ll prepare second answer.

  1. There is no predefined number of users. I’d like to be able to scale as much as possible (within reason) without running into issues, whether that be 10 users or a thousand.

  2. While not implemented yet, yes, messages will be saved to a database. This is so that when new members connect, I can retrieve a history of messages.

As to your final comment, I am using socket.io. The current desktop app connects to a barebones node server and communicates via socket.io, and currently does not use Meteor in any way.

If I understood you correctly then basically your questions are:

  1. How many concurrent chat users Meteor oplog can handle without issues
  2. How to integrate 3rd party authentication to Meteor accounts system

Is that correct?

I haven’t worked with Electron but I don’t imagine there would be any problems with using Meteor’s user authentication system for your use case.

The trick is that the way to scale your system with Meteor way would be by… not using what Meteor is best at. :wink: That means not using the data-sync feature allowing other users to sync their client state with the database, but to get the new messages from streams ommiting the reactive database writes and reads (making the writes non-reactive).

There are few Meteor-based chat applications that do it this way more or less, you can check f.e. Rocket Chat.

2 Likes

I’m not familiar with Meteor’s MongoDB Oplog system but after a quick read I’m gonna say yes.

Also, yes, how to authenticate users in my Electron app using the accounts system from a Meteor backend.

Yea, as mentioned the desktop chat app isn’t using Meteor at all. It’s just a plain Electron/Node/React app.

As per user authentication, how would I do that though? I have been unable to find any relevant documentation. It’s not like I can call Meteor.loginWithPassword() from the Electron app.

Sorry, I had wrong impression that you would be rewriting your front-end too.

Then, the answer is - personally I wouldn’t bother with such a structure. It’s possible to achieve but not worth it imho.

You will spend way more time rewriting stuff and forcing it to scale than you would to just adopt some 3rd party authentication system.

That said, if you want to make it work, you will need a DDP-client for your front-end app that works with DDP-based authentication. There are libraries on Github that achieve that, but they’re old and most probably outdated.

To confirm, when you say

I wouldn’t bother with such a structure

what structure are you referring to?

I am fairly against using third party auth systems. They are usually more trouble than they are worth, especially for such a critical part of an app.

Javascript client not being a Meteor app, with Meteor backend, using Meteor auth system to write a chat application.

You also mentioned:

You will spend way more time rewriting stuff and forcing it to scale than you would to just adopt some 3rd party authentication system.

Do you have any examples of what kind of scale issues?

I’ve not been in situation where I’ve thousands of concurrent users chatting simultaneously so take my opinion with a grain of salt, but I don’t think the expectation of scaling indefinitely without careful engineering at the platform level and not experiencing any performance issues is a realistic one, there are reasons why those platform as as service exist.

I also tend to agree with gusto statement above.

Which statement is that?

Apologize for the ambiguity, the following statement:

I’m really just interested to know if Meteor will have a problem performing the duties of both the current node.js app (that is, handling a bunch of socket.io messages) and serving a web application. Obviously, being able to just have one server side app and the one desktop app to manage would be easier than having 3 different components to manage.

If you know ahead of time that certain parts of your app are going to draw on resources heavily, I’d build anticipating a move to a microservice.

For instance, we listen for mailgun notifications. If users are batch sending, then these can often hit several thousand requests in just a second or two, typically enough to crash a galaxy container, or at least grind things to a halt. That’s not something I’d like to scale with galaxy. So we have some super simple node scripts running on DO servers to handle those requests, and scaling those up is much more cost effective.

3 Likes