I want to do a fairly simple implementation of a chat app using rails. from a theoretical standpoint I feel that ajax streaming pattern should be the way to go. However I am not sure, how it works and what are the potential disadvantages of this pattern?
Is there anything better that I can use. My requirement is to have four people on same web page and be able to see each others chat messages immediately in a group chat area. :)
It's a simple test app kind of thing. Any recommendations or pointers to implementations of streaming pattern would be helpful.
Cheers
Should keep you busy for a bit:
http://ajaxpatterns.org/HTTP_Streaming
Related
I need a way for my web application to send push-notifications to the client side. Realtime is not a strong requirement, near-realtime is okay. I don't need anything fancy, just sending a string to the client every now and then, nothing more. What's really important is that the solution must be very simple and low-profile (performance-wise mainly). Could you give me advice on which framework to use?
Many people would say SignalR hands down, but I'm not sure about the performance part. It is not disqualified, I'll tell about my doubts below, and I'm also interested about any insights you may have about this, but the main question stays what I wrote above.
I read this article recently. What it provides is a long-running request pattern with only a few classes, a little IIS & async magic and nothing more. Even if you have an IIS connection limit of 200, it will barely use up any of those connections. Compared to this, SignalR is as complex and heavy-weight as a nuclear power plant. It comes with half a dozen different DLL's (like OWIN, which I haven't heard about before, and even after a bit of Googling, I can't figure out what it is). The performance wiki page of SignalR starts by suggesting to increase your concurrent request limit to a ridiculous amount. So I'm guessing it's not using the aforementioned "trick". I'm not exactly sure how bad that is, but in the light of that article, it doesn't sound good.
If you really want to push messages to the client, SignalR approach is very good. As far as I know it works with web-sockets. Try to digg this way. Here is some article for the beginning:
http://blogs.msdn.com/b/youssefm/archive/2012/07/17/building-real-time-web-apps-with-asp-net-webapi-and-websockets.aspx.
For mobile apps I would use great library PushSharp. https://github.com/Redth/PushSharp
With help of PushSharp you can send notifications to any mobile app: WindowsPhone, IOS, Android, Blackberry etc.
Please note: sending push notification differs from platform to platform.
Keep in mind approach with pinging server all the time and checking for new messages. It is probably the easiest way.
I use SignalR and toastr.js. SignalR can scale to thousands of connections. There are also native SignalR clients for iOS and Android (check out Signalr-ObjC).
Since noone answered about the resource requirements and my doubts about SignalR, which was the key question here, I'm accepting this as an answer: http://www.codeproject.com/Articles/27107/Scalable-COMET-Combined-with-ASP-NET .
I am going to design a website using ruby on rails. And one of the features i want to implement is the chat functionality. Where users can chat with the other users/members of the website. What i should be using or in other words start learning in order to design something like that ?
Is XMPP the answer. if so, i would be glad if someone could be a bit descriptive on where to go from there and/or suggest some books. thanks !
I said XMPP because i know Facebook uses that and i plan to create something similar
Protocols can become a pretty hairy topic, implementing a well-working protocol yourself can be pretty daunting without prior experience. Especially if it has to do with (near) real-time communication between several parties. If this is supposed to scale to any significant number of visitors, implementing this correctly can be pretty tough.
XMPP is a protocol that is already well established, is shaken down and already has many stable implementations. So when using it, you do not need to worry about designing or implementing the protocol anymore. For that reason, I'd really recommend it. It's also a rather easy to understand protocol, even if you will have to spend some time reading up on the basics in the beginning. Look neigh further than http://xmpp.org for documentation.
Setting up an XMPP server can be done in minutes, depending on your OS and the server you choose. The caveat is that if you want to customize the server at all, you will have to learn about the innards of it as well to some degree, which may or may not take some time.
The bottom line is: choosing XMPP and existing XMPP libraries and servers, you get 90% of the functionality for free and can concentrate on implementing your client. The question is, how much will you have to dig into the details of XMPP and the server, will this take longer than rolling your own protocol and will your own protocol suit your needs in the long term as well as XMPP would?
You always have to think about how much you want to spend on implementing this.
If you go with XMPP you will be able to run a XMPP standard chat server (outside of Rails) and should be able to use a JavaScript Client with a XMPP to HTTP Bridge.
A project a quick Google Search brought up doing this is Strophe.
But I'd argue that you should think long and hard about if XMPP really suits your needs and if you really want to go through all that trouble for a Chat.
Implementing your own is also not straightforward, especially when you are writing all the long-polling and signaling stuff yourself.
But it's not impossible and should give you a simple working solution in a couple of days.
Doing the chat yourself in Rails will require you however to use an alternative Database since Rails can't store data in-memory between requests and persisting chat data in ActiveRecord seems like not a very scalable and good idea.
Using XMPP obviously has the benefit of your users being able to connect to your Chat service using iChat, Jabber or any other XMPP Client..
I'm trying to write a scalable interactive chat application for an existing high traffic website. It needs to be scalable on day 1, and chat's concurrency and multi-broadcast issues make it a tricky thing to scale.
My initial plan was to write the whole thing in rails and refactor the chat server into erlang later.
Although I am an experienced PHP dev and sysadmin, both node.js and RoR are new and extremely alien technologies to me, so I could use a little help understanding the core concepts and applications in this scenario. With so many new technologies, it is hard to understand them all.
Firstly, I recommend you review http://ajaxim.com/. The software is a pre-packaged version of what you want that relies on Node JS (far easier than rolling your own).
If you still want to write something yourself and have no experience with either technology, I recommend you review some introductory materials:
Node JS and Rails
The two sources are not free but will give you a quick one hour crash course on each technology.
You can also have a look at http://pusherapp.com ! This is if you want to implement a chat app right away.
If on the other hand, you want to implement one all by yourself, Node.js + Socket.io is your best bet. However, if you want chat rooms and stuff, have a look at this:
http://github.com/shripadk/express-juggernaut-demo
This demo app uses Express.JS framework and Juggernaut 2.
I would suggest going for only Node.js if you are building apps that require high concurrency. Its fairly easy to implement a chat room using Node.js compared to other server-side languages (mainly thanks to modules like socket.io). The event-driven architecture of Node.js makes it really easy to implement such stuff. The only catch with Node is that you have to think everything asynchronous! If you are good at Javascript then Node.js should be easy to learn.
I am building a site that has a lot in common with a person-on-person chess site. I was thinking of using Rails for the front-end(User Registration, Navigation, etc) and something like Scala or Erlang for the engine(Game state and maybe AI). I was wondering -
Is this a good situation to use that type of design?
How exactly would be best to divide up the functionality between the components?
How would they best communicate with each other?
I'm open to any technologies or ideas.
If you're using Rails for the front-end, why not use Ruby?
If you like the idea of using Scala, why not use Lift for the front-end?
Chess is turn-based, and has a very simple board that can be handled with HTML and/or Javascript enhancements - so the basic model flows quite nicely with existing web frameworks.
With this in mind, Rails is a great choice for creating a web-based application. Rails is not just limited to crud applications, and in fact I think can write your entire app in Rails/Ruby - you don't really need to have an external engine.
Within the browser space, polling for turn updates can be done using XMLHttpRequest and a database can maintain the current game and turn state.
Looks like a simple Lift application to me. I'm not experienced with Lift, mind you, but it doesn't seem particularly more complex than the chat application that is so often demoed.
I would start by reading http://www.htdp.org/ How to Design Programs. The questions you have asked are very broad and difficult to answer without prefixing statements with "I believe that..."
I would code it in clojure (but that's just me).
I'm currently developing a suite of online games, using Scala. It's been absolutely fantastic - my game logic is much easier to get right with the static typing etc, and dealing with server/client protocol (a flash client, in this case) is made simpler via the use of Google Protocol Buffers.
If you're a huge fan of RoR, by all means use that. I think most statically typed languages are terrible to program websites in (Java, I'm looking at you here), but Scala gets rid of 90% of the pain, and gives even more safety.
Of course, it might not be your cup of tea. But I'd try just doing the entire thing in Scala, and adding another layer if that doesn't quite do it for you.
For question 1 Yes
And for 2 and 3 you need to give more information in order to get an answer that could help you.
Now I'm doing something like you but for the front end I'm going to use Grails. The reason are very simple: I like Grails, Scala and I want to mix them :)
Since Rails is already an effective Rich Internet Application framework because of the way it makes Ajax so easy, what is the argument for combining Rails with Flex and using Flex as the front end instead of HTML? A programmer friend of mine said he uses this combination because Flex is great for RIAs. My argument is that Rails is already great at that - why add additional complexity? Another big disadvantage of doing this, it seems, is that you cannot use HTML in your front end any longer because Flex makes this extremely problematic. That seems like a very high price to pay for whatever benefits this combination of technologies offers.
I think you want to consider this in terms of what your client app needs to do. If you can accomplish everything you need within rails, then there's no real need to go to flex. If you need more client-side control, then you can build a flex app and make the rails app just a web service.
It all depends on your definition of what a RIA (Rich Internet Application) really is. To some, an AJAX enable web application might fit the bill. To others, a RIA includes highly stylized elements, a high level of interactivity, and a good bit of animation.
If you're one of the people that think along the lines of the first requirements, then great. An AJAX enabled RoR app is going to be enough for your RIA. For those who belong to the second group, RoR is yet another way to provide the data backend for a RIA that uses Flex/Flash for it's presentation.
Personally, I believe that RoR combined with Flex is going to give you a much richer, dynamic, and engaging RIA than a standard AJAX enabled web application.
I wasn't aware people used Flex and rails all that much. But using Flash/Flex does give you a bit more processing and visualization power. Also, you can have native AMF support from Flex for efficient data transfer.