What are the differences between using a websocket based technology versus a realtime database like RethinkDB? - websocket

Recently, I found myself wanting to develop a web application using real-time technologies. As far as I see, I have two ideal solutions.
Use WebSockets. (in my case Socket.io)
use a real-time database like RethinkDB (I guess stuff like Pusher and PubNub also fall into this category too)
I am lost, however. What are the technical differences between these two solutions? When should I prefer one over the other?

They actually work really well together. Using RethinkDB changefeeds to watch for changes in the database and then using socket.io to pass those changes to the client(s) is a good way to use them in tandem. I'd recommend taking a look at Jorge Silva's answer to this similar question.
socket.io vs RethinkDB changefeed
I was only familiar with this because of a tutorial I did with an interesting tech stack of React, Redux, RethinkDB, Express, & Socket.io. I'm not sure what you're using for your front-end/view layer but this might be helpful for learning how to integrate RethinkDB+Socket.io
http://webapplog.com/reactive-web-stack/
Good Luck!

Related

Handling realtime in laravel

I know this will be closed question but I can't find what I want so I need to ask pros over here.
What is the best option for real time content in laravel app like messages, notifications and even loading new post as example.
Besides using pusher or other services.
Something like nodejs and socketio but
what are the best
options for laravel apps?
If you are wanting to take advantage of Laravel's Broadcasting functionality then going with a supported driver is likely best to get you started.
Which means that if you don't want to use Pusher then it is a combination of Redis and Socket.io.
Our small team doesn't have a dedicated dev-ops team, so we went with Pusher and have had a good experience with minimal server config. We do also use Redis for pubsub communication between a couple of microservices, some api throttling management, and of course queues. It might be worth noting that if you are a Laravel Forge user it provisions Redis out of the box for you too.
You have to think of your software needs.
Pusher comes with a Free Tier, and its easier to implement than Socket.io
Setting up Socket.io will come with some learning curve, you may want to expend your time on other functionality of your project. But hey its free right? unless you consider time more valuable, which is almost always the case when it comes to programming.
With Pusher, you can quickly start your project, focus on other less trivial requirements.
Socket.io may save you money, but only once is running.
If your project doesn't consume the free tier completely, it's a no brainer.

What is common approach for offline fist app with GraphQL?

I've read a lot about GraphQL and I like it. Especially in conjunction with Relay and React-Native. But while thinking about whole app architecture I can't fill one gap. In order to make reliable app in should work well if there is no internet connection. So common scenario is to write REST responses to DB and reflect these data to UI. But in case GraphQL idea is that data might be incomplete.
So what is the best/common approach to store data that come from GraphQL backend in order to be offline available ?
I'm searching the same :P
With Apollo you can get an offline graphql approach, but is not offline first. I think this does not exist at the moment :(
Another alternative is Realm with MongoDB:
"MongoDB Realm will combine Realm, the popular mobile database and data synchronization technology, and MongoDB Stitch, the serverless platform for MongoDB, into a unified solution that makes it easy for you to build powerful and engaging experiences on more devices." - August 2020

Phalcon php vs node.js

We are going to develop rest server for our application (and all logic is on client javascript).
So we thought to use Phalcon php, but we also need to create realtime chat system, which is much more easy to do using node.js. This made us think about using node.js instead of phalcon
Unfortunatly, we are not good expirienced in node.js, we love phalcon for its performance and internal beauty.
The quiestion is, did anybody compare phalcon and node.js performance? May be it's better to use node.js only for long polling chat requests, but i dont like when project is connected with so different tools.
You are trying to compare two different things IMO.
node.js has a lot of power and flexibility but so does Phalcon. If you want to create a chat application with Phalcon, then you will need to implement some sort of polling mechanism in your browser that would refresh the chat window every X seconds. Getting/Inserting the data from the database will be Phalcon's job. Javascript will be used to do the polling i.e. refresh the chat page every X seconds.
The problem with this approach is that you might be hitting your web server every X seconds from every client that has the chat application open - and thus refreshing the chat contents, even when there are no messages. This can become very intensive very quickly.
node.js has the ability to send messages to the subscribed clients instantly. Web sockets can do the same thing I believe.
Check this video out, which will give you an idea of how this can be achieved easily:
https://www.youtube.com/watch?v=lW1vsKMUaKg
The idea is to use technologies that will not burden your hardware, rather collaborate with it. Having a "subscription" notification system (such as sockets or node.js) reduces the load on your application since only the subscribed clients receive the new messages and no full refresh is needed from the chat clients.
Phalcon is great for the back end with its speed and it can be used to construct the message which in turn will be passed to the transport layer and sent to the client. Depending on how you want to implement this, there are plenty of options around and you can easily mix and match technologies :)
as #Nikolaos Dimopoulos said, you're trying to compare two different things.
But here is my advice, while you're experienced with PhalconPHP framework, and you want to benefit from Phalcon speed and performance, you can implement the web app in Phalcon FW, and the chatting system in Node.JS as a service.
If your web application "The Phalcon app" needs to push messages from the backend, you can use http://elephant.io/ library for that, I have done this before with Yii framework and Node, and it's working perfectly.
My advice is to use what you already know, experimenting with nodejs just for the chat application.
Mainly because you said you do not have experience with it, so, because the chat app is something a lot of people made you'll find plenty of examples.
By doing so you will learn a lot from node and might even think about migrating from Phalcon if it suits your needs, using the features offered by expressjs for example.
I would not choose one over the other based on performance.

Is there a socket.io port to Dart?

I've taken a look at the basic websocket capabilities in Dart, using this simple example:
https://github.com/financeCoding/chat-websocket-dart
But I was wondering if there's a nice library I could use to build a realtime online game using websockets. I've had experience in this using node.js with socket.io, which worked out quite well. I need to be able to have "rooms", join rooms, leave rooms, broadcast to clients in a room, etc. as well as some nice notion of connection "health", reconnection etc. So what I'm asking is if there's a nice library for dart that has similar functionality? Even cooler would be a library on top of that library that could enable nice RPC functionality with variable syncing etc. such as http://nowjs.com/ which achieves this using socket.io. But I guess that might be too ambitious.
If anyone's had any experience or found a project which is similar to what I'm talking about, let me know :)
Duct is clone of Socket.IO in Dart which aims to be protocol-level compatible with the original implementation.
https://github.com/petrhosek/duct
Sorry, at the time of this writing, I'm not aware of a socket.io port for Dart. socket.io is nice because it has a bunch of implementation options for browsers that don't support Web sockets.
Sounds like a good idea for a hackathon project!

What is a good choice for Fulltext indexing when developing a OSX application?

Hy,
I'm implementing an IMAP client as a Mac OSX application using MacRuby.
For the sake of offline availability, I wanted to allow fulltext indexing and attribute based indexing of all messages. Attributes include common E-Mail stuff like from:, to:, etc...
This would allow for advanced results sprinkled with faceting, analytic calculations and such.
Now I'm unsure about the choices and good practices when it comes to integrating such a search feature. I have a strong web development background, therefore my intuitive action would be to setup a Solr server and start feeding it with data. This might just work theoretically, as I could write an Agent that manages the solr instance for my application in the background. But to me, this approach seems like an infrastructure hassle.
On the other side, I've read about people using the FTS3 functionality from SQLite. This approach is easily accessible by CoreData. I haven't used SQLite's FTS3 but I don't think it is as powerful as Solr can be.
What is your weapon of choice for a use case like mine?
I'm mainly interested in solutions that are actually in use by Objective-C/Cocoa/MacRuby developers.
In you're going to develop the app with Ruby give a try to picky. It is very simple to use.
There is an Objective-C Lucene port
http://svn.gna.org/viewcvs/etoile/trunk/Etoile/Frameworks/LuceneKit/
I have not used it, but in your situation, I'd at least check it out. In my experience, SQL based full text search can't compete with Lucene, but haven't tried SQLite for this.
EDIT: just noticed the ruby tag -- this started out as port of Lucene
https://github.com/dbalmain/ferret

Resources