Welcome Guest, Not a member yet? Register   Sign In
Real time - Which is the best way?
#1

Hi, I'm here to ask one thing: which is the best way to handle notification to user like facebook? Do you reccomend me socket.io or any other things?

Thank you!
Reply
#2

How large is your user base?

Depending on what kind of functionality, how large your active user base is, and how 'real-time' you need it to be, you can choose between polling or websockets.

At the end of the day, websockets will scale much better than polling and is more real-time. If you're wanting to go the easy route of websockets, I'd recommend nodejs with something like socket.io. If you're wanting to build an app that can scale to the roof, I'd recommend using Elixir + phoenix.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#3

(This post was last modified: 07-24-2017, 08:49 AM by theedo.)

(07-24-2017, 08:43 AM)albertleao Wrote: How large is your user base?

Depending on what kind of functionality, how large your active user base is,  and how 'real-time' you need it to be, you can choose between polling or websockets.

At the end of the day, websockets will scale much better than polling and is more real-time. If you're wanting to go the easy route of websockets, I'd recommend nodejs with something like socket.io. If you're wanting to build an app that can scale to the roof, I'd recommend using Elixir + phoenix.

My website still under construction, I'm at the point to do the real time. I know that websockets are not available on all browser, is it a problem?

However, I'll see elixir and phoenix because I don't know them.
Obviously I'm using Codeigniter to build the website's system.
Reply
#4

(07-24-2017, 08:48 AM)theedo Wrote:
(07-24-2017, 08:43 AM)albertleao Wrote: How large is your user base?

Depending on what kind of functionality, how large your active user base is,  and how 'real-time' you need it to be, you can choose between polling or websockets.

At the end of the day, websockets will scale much better than polling and is more real-time. If you're wanting to go the easy route of websockets, I'd recommend nodejs with something like socket.io. If you're wanting to build an app that can scale to the roof, I'd recommend using Elixir + phoenix.

My website still under construction, I'm at the point to do the real time. I know that websockets are not available on all browser, is it a problem?

However, I'll see elixir and phoenix because I don't know them.
Obviously I'm using Codeigniter to build the website's system.

I'm pretty sure things like Socket.io have fallbacks for browser issues as does phoenix.

Phoenix and Elixir is an entirely different world of programming so it's a lot more difficult to do if you haven't done anything outside of PHP and Javascript, but it's also how Whatsapp was able to handle billions of real time notifications on just a handful of servers. Smile
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#5

(07-24-2017, 09:16 AM)albertleao Wrote:
(07-24-2017, 08:48 AM)theedo Wrote:
(07-24-2017, 08:43 AM)albertleao Wrote: How large is your user base?

Depending on what kind of functionality, how large your active user base is,  and how 'real-time' you need it to be, you can choose between polling or websockets.

At the end of the day, websockets will scale much better than polling and is more real-time. If you're wanting to go the easy route of websockets, I'd recommend nodejs with something like socket.io. If you're wanting to build an app that can scale to the roof, I'd recommend using Elixir + phoenix.

My website still under construction, I'm at the point to do the real time. I know that websockets are not available on all browser, is it a problem?

However, I'll see elixir and phoenix because I don't know them.
Obviously I'm using Codeigniter to build the website's system.

I'm pretty sure things like Socket.io have fallbacks for browser issues as does phoenix.

Phoenix and Elixir is an entirely different world of programming so it's a lot more difficult to do if you haven't done anything outside of PHP and Javascript, but it's also how Whatsapp was able to handle billions of real time notifications on just a handful of servers. Smile


Obviously I want learn something new ^_^, but I saw and I must say that Elixir and Phoenixframework are really hard for me ahah!
Reply
#6

I'd caution against using any brand new technology especially when it comes to scaling. Until a platform is proven it's a gamble if and when support or development may stop leaving you to rewrite your application. socket.io has been around for years and isn't going anywhere any time soon. If the unlikely event occurs that you have to handle volumes like WhatsApp you'll have the resources required to make that decision.
Reply
#7

(This post was last modified: 07-24-2017, 10:41 AM by albertleao.)

(07-24-2017, 10:15 AM)spjonez Wrote: I'd caution against using any brand new technology especially when it comes to scaling. Until a platform is proven it's a gamble if and when support or development may stop leaving you to rewrite your application. socket.io has been around for years and isn't going anywhere any time soon. If the unlikely event occurs that you have to handle volumes like WhatsApp you'll have the resources required to make that decision.

Phoenix is built on Elixir/Erlang which has powered telecom companies since the 1980, it's not new technology at all, it's just not object oriented and is functional instead.

Addition:

I'm not saying he should use Phoenix + Elixir but he asked for what's out there and I stated so. He specifically stated "Like Facebook" so if you take it literally, I described pretty well the different scenarios. If he wants something that is very powerful, proven, tested, and has been around for a long time, then you can go with something like Elixir. If you want something that's easier and still scales well you can go with nodejs + socket.io. If you want something that probably will crash quickly, try implementing PHP websockets.

And just to add, most 3g, 4g and LTE networks in the world are powered by Erlang. It is in no way new.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#8

I think that I'll use socket.io or something else with nodejs, because my project never will be like facebook ahah! I'm obsessed with how facebook manages all requests (json, script js etc).

However I coded some months ago a real time chat with socket.io all by myself but I had some issues, I write them here, maybe you can give me some idea:

1) we have two users, A and B. They connect on a private room only for them, when A send message he sees the message with the message sent by him, and the user B see the message as if received, but if user A open 2 tabs on browser, in one of them he sees the message that he sends as from another user, I think it was a mistake about the session/token (?);

2) Is possible to emit some message to an "array" of user? Instead: A make a post; B and C comment its; then D comments the post -> A, B, C receive the notification about D. Is it possible?

Sorry for my english, I wish that is correct.. ahah! And sorry also for this question, thank you for all your help, specially to albertleao Smile!
Reply
#9

No problem Theedo, just trying to answer your questions.

From what you stated, it seems like there is an issue with the way you're handling the different sessions as it's creating a new user everytime they open a new tab. I'm sure this has already been answered. Someone here might be able to help you but you'll probably have better luck asking the people over at socket.io. They have a very active Slack channel you can join and talk to people about.

https://slackin-socketio.now.sh/
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#10

(This post was last modified: 07-24-2017, 12:07 PM by spjonez.)

(07-24-2017, 10:32 AM)albert leao Wrote: Phoenix is built on Elixir/Erlang which has powered telecom companies since the 1980, it's not new technology at all, it's just not object oriented and is functional instead.

Erlang yes, Phoenix no. When Node was first released you could have said the same thing about it. Yes it was based off a language that was mature but the eco-system wasn't.

theedo Wrote:1) we have two users, A and B. They connect on a private room only for them, when A send message he sees the message with the message sent by him, and the user B see the message as if received, but if user A open 2 tabs on browser, in one of them he sees the message that he sends as from another user, I think it was a mistake about the session/token (?);

You can do this a couple of ways. Authorization middleware or send a unique property to identify the user when they connect and pass it back with messages to make the client assume the separate connections are the same user.

theedo Wrote:2) Is possible to emit some message to an "array" of user? Instead: A make a post; B and C comment its; then D comments the post -> A, B, C receive the notification about D. Is it possible?

Send JSON and decode it.

As a side note scaling is generally something you don't want to be too concerned about until you need to. Don't take shortcuts along the way, but don't over engineer a problem that doesn't exist yet. If you can't sell 10 of something don't worry about how you're going to sell 10,000.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB