23 ms·
Build a real-time Twitter clone with LiveView and Phoenix 1.5
- chrismccord 6y agoWe are really excited about this release! I also wanted the screencast to be a single take, so I'm happy to answer questions if there are gaps to fill in for things I could have explained more clearly.
- rglover 6y agoThanks for putting this together, Chris :)
- sertyrion 6y agoGreat work! I think the phoenix framework project really recognizes the power of "Defaults". Defaults for dev, user interaction, server, and client. Make useful things quick but also learn how and why they are chosen.
- thebigshane 6y agoFirst of all, great demo, and great showcase for this technology. I think it did a great job of showing its strengths to traditionally backend developers like me. I also appreciated the twitter analogy. I just couldn't help but think "Wait, Twitter doesn't have 'Update/Edit Post'!" :) I've heard that Blazor in the .net world has similar goals to LiveView, but I haven't gotten into it much. Can anyone confirm?
- zeroc8 6y agoYes, there are two Blazor variants. Serverside Blazor is basically the same thing as Phoenix Live View, client side Blazor is providing some optimized Mono runtime as webassembly.
- dnautics 6y agoFrom an empty repo, how many minutes do you think it would take one to do what Chris McCord did in Phoenix Live View in Blazor?
- zeroc8 6y agoI have no idea. Probably longer. But it is the same idea. The big gains come from going back to the simpler server side programming model. I'm working on a big Angular application right now for which something like Live View would be the ideal fit. That said, a switch to Elixir would be a very hard sell in my company. Blazor would be easier because it's .NET.
- dnautics 6y agoI also don't know enough about c#, to comment on this being a risk for blazor but having the BEAM's process isolation is absolutely critical to minimizing programmer error from turning into a let's say a DOS attack risk, or possibly worse. I worry that all these other platforms rushing to emulate liveview are missing that extremely critical component of this model. If you aren't certain about what I mean, I suggest watching Sasa juric's "the soul of erlang and Elixir" video where forward progress of the system is unimpeded by a panic or a process that attempts to hog processing via an infinite loop, both are detectable in the running system, and able to be easily identified (down to the malfunctioning function name) in the in-prod system.
- Scarbutt 6y agoYou are running this on localhost but won't interactions be slow if a user is 200ms from the server? Re-rendering templates every time on things that require high interaction also seems very expensive and an easy way to slow down your server when you have multiple users correct? or what I'm missing?
- chrismccord 6y agoyou are correct, you can't escape the laws of physics latency wise, but most web things we are all building, including 100% JavaScript apps require a round trip to the server. For example I can't post tweet without a round trip to twitter. On the LiveView side UX wise, we apply css loading states to the interacted elements, so the user is provided feedback while awaiting an acknowledgement. On the server, our templates are precompiled and do change tracking. So we only execute the elixir code that is necessary to render the parts of the template that changed. The rest of the calls are noops. From the top down, it appears like an extremely heavy approach, but with our change tracking and diffing, it's actually incredibly optimized. Also note the Erlang VM was made to handle multiple users, as we showed in our "The road to 2M connections with Phoenix" blog post a couple years ago. More connected users will mean more memory, but Memory is cheap, and the platform scales well enough that opening a websocket on all pages as a matter of course is completely viable. Hope that helps!
- chrismccord 6y agoI also forgot to mention we provide optimistic UI features with our loading states and annotations. For example, in the screencast, the "Save" button has phx-disable-with="Saving...", which applies on client instantly and stays until an ack is received. You can leverage the loading states as well to toggle entire containers for a happy medium between traditional optimistic and instant user feedback.
- josevalim 6y agoLiveView does not re-render the template on every interaction. LiveView actually sends patches over the wire, which is typically smaller than a hand-written JSON response. The screencast linked above has a good example of this, where clicking the "retweet" button sends a minimal payload, since we know the exact position on the page. LiveView also uses a long-running WebSocket connection and that reduces the amount of data sent over the wire compared to regular requests/responses, as you don't need to encode headers, cookies, etc. Finally, if you are worried about latency, you can call "liveView.enableLatencySim(200)" in your browser console, and you will be able to emulate how your application behaves over high latencies.
- miki123211 6y agoAny hope of getting this as a text article, or even a git repo? Blind user here who can't see code embedded in a video, but can read ascii-text with a screen-reader perfectly fine. People who don't enjoy videos for various reasons would probably like a text version too.
- thex10 6y ago> People who don't enjoy videos for various reasons would probably like a text version too. Yes this. I went to the video eagerly looking for a repo link and was disappointed not to find one.
- anw 6y agoHi miki123211, I wrote up a transcription for you. It details the code he's talking about, along with the context of what's going on, and why. https://pastebin.com/raw/WxH0uAsf https://pastebin.com/raw/WxH0uAsf If Pastebin doesn't work for you, let me know and I can get it hosted at a different location. My apologies if there are any mistakes in this. I'm not familiar with Phoenix, but found this video very interesting, so wanted to make sure it could be shared.
- miki123211 6y agoThanks, that works. The raw link is perfect for accessibility, as there's no garbage on the page.
- praveenperera 6y agoThank you for doing that, good job!
- sdwolfz 6y agoI'm really amazed this sort of functionality can be implemented in such a nice and clean manner. Your presentation is mind blowing! Just out of curiosity (please don't consider this as a feature request, more like a thought exercise), in case you wanted the application to have offline editing functionality, could the framework provide it in a similar manner? having a generic JS handler that manages pushing state when an internet connection is available again and exposing hooks that you can implement to handle data consistency? Of course in this case the data payload passed through sockets would be bigger as you would need some identifiers to make sure for example increments don't get duplicated, and there could potentially be different strategies for solving data conflicts (CRDTs for example). But would it need extra back-end support for this or would it be enough to have engineers manage state through the current handlers?
- chrismccord 6y ago"offline support" is strictly on the side of needing to run a lot of code on the client, so this is where we draw a line and say you need a js framework, of which there are number of great options. We have javascript interop via phx-hook, so it could be made to work, but you'd necessarily have to have a lot of js running on the client, and any feature you wanted to work online & offline would not share a code path or need js, thus client side rendering and templating gets involved and suddenly we're writing a SPA. If we're strictly talking allowing the edit of a textual input and syncing on reconnect, it would be straight forward to do with LV and some small js hooks, but the moment you start adding offline UI features you'll need a js library. The funny thing is last I tried to use Google Docs offline, it locked the page in read-only mode, so offline mode even in the SPA space isn't just a given – you're definitely opting in to some necessary complexity.
- sdwolfz 6y agoSounds fair, thank you for your reply!
- mangoman 6y agoCongrats on the launch! I've been following this for a while and played around with it a bit, I'm excited to get my hands dirty with this. How does reconnection work? lets say someone is using the site, and you do a deployment, rolling the nodes over. Does live view simply reconnect to another node without any interruption from the user's perspective?
- chrismccord 6y agoConfirm. LiveView will apply css loading state classes, which are user defined, but we generated css by default in new apps to lock the UI with loading cursor, and show a top loading bar. On reconnect, which happens automatically, we rematch the DOM with any changes, and we also send up any user form input beforehand so client state is lost that was in progress. We already have reports of users pushing bugs to their systems and the UI seemingly being unaffected because the LiveViews automatically recover, wether from a disconnect or a crash on the server.
- deleted 6y ago[deleted]
- AlchemistCamp 6y agoHow stable do you expect LiveView's API will be going forward? I'm especially invested in this since I've just rolled out an alpha of a project that may incorporate it in the future: https://phoenixigniter.com https://phoenixigniter.com
- chrismccord 6y agoAs always, I can make no guarantees before 1.0, but we have really focused on refining the programming model and APIs for the last several months, so we're in a good state currently.
- deleted 6y ago[deleted]
- andruby 6y agoHi Chris. I built a demo with LiveView a year ago and am very happy to see all the improvements. One thing I didn't understand from the video is how the :post_updated callback worked. It prepends the updated post to the list of posts. How come that doesn't lead to the same post being double in the list?
- josevalim 6y agoComponents IDs are unique. So once you try to render the same component, we know you simply want to update the current one. The same happens on the client. If the server emits the same DOM ID, the client just updates it in place too.
- nickjj 6y agoHey Chris, do you have any plans in the very near future to update the example LV repo to use all of the goodies in LV 0.12+ and Phoenix 1.5+ and perhaps even add more examples?
- darepublic 6y agoLooks interesting but I am not interested in making timelines .. is this Phoenix framework general enough to make arbitrary real time web apps?
- rglover 6y agoYes, think of it like Rails for the Elixir language. Phoenix -> Elixir Rails -> Ruby
- bostonvaulter2 6y agoBut without requiring all of the ActiveSupport patches to the base language!
- chrismccord 6y agoAbsolutely. We have extremely varied usage in the wild. From sports/content websites with tens of millions of users (bleacher report, cars.com), to folks running social/chat services with millions of persistent connections, to folks running Phoenix on embedded systems. And as you would expect, there's a ton of "boring business app / JSON API" usage in there as well, so we have a good story about generalized use. The goal of the screencast, as I outlay in the beginning is to show how easy LiveView makes it to build interactive and real-time applications, and a social timeline was a decent way to do that ¯\_(ツ)_/¯
- rupurt 6y agoHappy LiveView user here :) Can confirm it can be used in many scenarios. One of my favorites is streaming realtime data to a chart. I serialize my data as JSON in the LiveView template and read it back in from a Hook. Saves me time by not having to create a separate API endpoint. e.g. <div phx-hook="MyChart" data-days="<%= Jason.encode!(days(@balances)) %>" data-amounts="<%= Jason.encode!(amounts(@balances)) %>" > <div phx-update="ignore"> </div> </div>
- cultofmetatron 6y agoI'm currently using it to make a restaurant POS. It's very flexible. Everything composes like lego pieces in a very clean and straightforward way with surprisingly little magic.
- codegeek 6y agoI have been watching Phoenix/Elixir for a while and wondering if it has gained a lot more traction compared to say 2 years ago ? My choice of full web app framwork is Symfony/Laravel (PHP) or Python (Flask/Django) but I really like what Phoenix has to offer. However, does it have a mature ecosystem now ? What about deployments and tools around it ? Does it work with generic web servers like Nginx or does it run its own http server ?
- t0astbread 6y agoWouldn't you typically run Nginx (or something similar) as a reverse proxy anyways in production?
- codegeek 6y agocorrect. I was just wondering if it also has inbuilt http server as well to process things like static files etc or is that completely on 3rd party tools like nginx (which I love btw). Kinda like in Golang where you could technically use the static file server but I always use nginx for those things.
- innocentoldguy 6y agoCowboy is Elixir's built-in HTTP server. You can configure things like Nginx or Haproxy as you would with most other frameworks.
- 6y ago
- neya 6y agoI was a Rails user for almost a decade. I switched to Phoenix/Elixir 3 years ago. Elixir is a super simple language. It has no OO concepts and everything is functions first. In fact, it's so good that I started teaching it for universities. All my production web applications are now fully on Elixir. Elixir is one of those languages where everything has been done perfectly as of the time of this comment. When I say perfect, I mean, there has been never once in my career where I hit a roadblock due to the language's limitation or complexity or flawed assumption. I faced this with other languages, but not Elixir. I'm currently a full time consultant writing, teaching and deploying production apps for clients in Elixir. Most of my apps have served my clients well beyond my contractual agreement. It's almost deploy and forget because of Phoenix. It also scales amazingly well. It's extremely performant. I just re-wrote the entire crappy mess Wordpress core in Elixir and enjoyed the process. In any other language, I wouldn't be saying the same. It's really an enjoyable language that forces you to rethink the way you write code. Don't be put off by this statement, I mean that in a really good way. And once you start thinking interms of functions, you just won't touch any of those terrible OO programming paradigms (Eg. writing for loops, nesting conditionals, etc.). You will start writing maintainable, beautiful code. You will appreciate Elixir a lot especially if you have a background in horrible programming languages like Javascript. You will literally start finding ways to use Elixir in your entire stack like I am. It's that good. Enough said. Give it a shot.
- mwcampbell 6y ago> I just re-wrote the entire crappy mess Wordpress core in Elixir and enjoyed the process. That sounds useful. Do you plan to make a product out of that?
- faizshah 6y agoQuestion to the former Rails devs out there: We mostly see threads fawn over Elixir and Phoenix, have you experienced any downsides to switching? Anything you miss from Rails? I'm convinced to give it a try after that demo!
- buf 6y agoAlso curious. I've been a django user for 5 years and a rails user for 9 years. I mostly use rails as an API these days and a React app for the front end.
- mercer 6y agoI'd say I sometimes miss Rails' ecosystem, but the many advantages of Phoenix and especially LiveView are worth that small downside. To someone who uses Rails/Django with React, I'd describe LiveView as something that offers pretty much everything you're used to, but with the React part consolidated with the server-side of things. I've been playing around with LiveView since it came out, and have been using it for 'serious' work for the past year or so, and I still regularly discover ways in which this setup simplifies things, makes development faster and more fun, and saves me from various potential security flaws or 'busiwork'. Imagine that your store (Redux, whatever) and view (React) ran in the same place as your backend. Direct access to the database and the rest of the backend, no need to carefully consider whether it's really worth it to increase your js payload with library x, no constant context switching, no building and maintaining of, essentially, two completely separate applications, no need to make sure your API endpoints are properly versioned, or that they don't expose data that shouldn't be exposed, or that they send only the data you need. Little to no need for rube-goldberg js pipelines, and significant less time spent dealing with synchronizing state between server and client. I'm probably forgetting some other advantages. There are some things where LiveView doesn't seem ideal, but I've found that even in those cases I prefer using LiveView wherever I can anyways, and then I do the specific javascripty bits wherever I need them.
- itake 6y agoIt seems like a lot of companies are moving to Go for fast services. As a rails dev for 10+ years, I am looking at Go instead of Elixir and Phoenix, b/c Go is a much more popular language than Elixir.
- chriszhu12 6y agoI've been following this project for 5 years now, and I've really hoped it would take off. However, part of what made (and to some extent, still makes) the Rails framework so great is the surrounding ecosystem of well supported gems that makes building tedious things a breeze. I built a few things in Phoenix in the past, and while the core framework is very simple and elegant to use, I recall having to write my own file uploading library because the one that existed had almost no documentation. This made me really hesitant to adopt Elixir / Phoenix stack for any projects I'm serious about. I was hoping there was a world where most of the old rails community moved onto phoenix, but in the time this project has been around, it seems the backend web stack has really fragmented into a multitude of Node, Go, python, etc, while Phoenix hasn't really grown its mindshare. For former Rails / Django devs who has made the switch: what are your thoughts on this?
- ithrow 6y agoThis happened to me with Clojure. You really get to appreciate languages with big ecosystems when working on niche languages. It's sad because these languages are more enjoyable to work with IMO. Thy are better cause they had the advantage of being created much later than the mainstream ones but that also means they had hard competition.
- jtth 6y agoSeriously. I would love to work at this level of abstraction in Clojure, but to do something that is trivial in Rails with something like Devise is a chore in Clojure, and you have to put it all together yourself. Of course this makes it excellent for learning, but not so great for deadlines. More and more I think I might've made a mistake trying to do basic CRUD web stuff in Clojure for my current project.
- syspec 6y agoInterestingly one of the creators of Devise is the creator of Elixr
- 6y ago
- rubyn00bie 6y agoOh, holy crap, I'm stoked, as someone who has just started using LiveView after like too many years of single page apps... all I can say, is "oh fuck, did we get it wrong." The experience is truly great. Also, LiveComponents are pretty awesome since they don't have their own process, just mount in existing LiveView, it makes 'em really easy to reuse and performant (at least from my experience so far). Writing UI code, in a language/environment that has first class support of pattern matching is like a dream for me. Seriously, pattern matching is sooo good when you don't have fucking classes and objects and bullshit "abstractions" in the way of your data. Also, if you took a stab at it before 1.5, try it again. This release has all the goodies to make it nice and documentation to go with it... I'm stoked to delete the phx.live generators I copy-pasta'd into my repo from phx master a couple weeks ago trying to get my bearings. Truly awesome work on this! Thank you so much. Also, pro-tip, use the generators at least once, even if you have already used live view without 'em, because now there's more or less an official pattern for how to organize yer live code and it really helps.
- czbond 6y agoI feel your pain on SPA's.... I feel like code velocity drops on small teams. What about LiveView/Phoenix made the process more enjoyable - let's call it 'less painful'?
- rubyn00bie 6y agoOh, yeah, here we go: 1. Tooling, yeah, you gotta have node installed, but that's pretty much the last time you have to touch it. I'm not anti-node or anti-js by any means, but the tooling around them often turns me off. Getting to do front-end work without _having_ to think about 'em is a breath of fresh air. 2. Less duplication of effort. I don't need to define schemas twice... once in the "backend" and once in the "frontend" application. You don't think this is bad until you spend two hours adding a adding, removing, or changing a simple property to your application because you have to update the backend, the backend's api docs, its tests. Then on the frontend, adjust the schema, adjust the frontend tests, and finally see if it's working. 3. Faster iteration. I prepare a new context, and can immediately consume it in a view. Views are reloaded instantly when changes are made during development reducing the time it takes to get feedback and increasing how fast I get shit done. Also less duplication of effort REALLY helps here... 4. We (at least me) got S(F)PA idea totally fucking backwards. The idea isn't to make you're entire web site a Single Fucking Page Application, but to make individual (single) pages which NEED TO function like applications do so... Quintessential examples that do _NOT_ need an SPA: a fucking FAQ, about, or contact pages. In fact, having an "application" on top of them is more burden than not. 5. CSS is really powerful these days and provides a lot of what the 2008-2012 JS movement was trying to do. If I combine that, with being able to re-render only part of the page, I've got almost the entire flexibility of what SPAs offer with almost none of the complexity. 6. Going to a new page, and causing a page refresh, but totally knowing the next page isn't going to be broken because of the previous page's state. Page refreshes are awesome. Growing up on 28.8k that wasn't the case, but ever since I got above 10Mbps its really not something I ever even notice (though I do notice when pages are broken that shouldn't be because they're SPAs and not just fucking content). I could probably keep rambling but I'll stop here...
- gprasanth 6y agoI've been writing code for close to 10 years now and I see this and feel like what a beginner would feel trying to understand assembly code. Or someone hearing a similar but new language. Looks to me hours of work and learning got abstracted as under the hood "magic". It's like saying: Oh, so I've been weight training for the last 17 years and I should tell you Olympic silver is not too hard, see? Am I right in my thinking? or is learning to be this proficient with the framework not as time taking for a novice developer as I think it to be?
- lostcolony 6y agoAre you familiar with Ruby on Rails? Phoenix was built as a simpler equivalent, to leverage websockets, and to leverage the BEAM to be performant with high concurrency (i.e., what you generally want in a web server). Is it encompassing a lot of magic? Yes. But the quick growth in mindshare that Ruby on Rails attained back in 2005-2010 (part of which it still retains) was due to how easy it was for a novice developer to pick it up and build something useful. Pick it up and understand all the pieces, no. Phoenix is less Express/Martini in nature, more Spring/Rails (but more pleasant than either of those to work with, I would contend, but again, that's opinion).
- brightball 6y agoThere's no magic. It's functionality that's made possible by the BEAM. It's just one of those things that came out of realizing how powerful the runtime was for handling certain types of problems. When you combine a couple of those bits together, you end up with this. The only modern web problem that Elixir isn't ideally suited for is heavy number crunching. Otherwise it gives this amazing balance of efficiency, scalability, reliability, maintainability and capability that can't be replicated in any language that has a shared memory model.
- IanCal 6y agoI'm of a similar view to them, this felt like lots of magic or at least lots of gotchas I can see myself hitting. I saw two function definition types (def and defp), pattern matching input then requiring a caret for the variable name (?), passing in "assigns" but then referring directly to other variable names, pipes, etc. There's a lot there compared to when I've worked in Erlang.
- leeoniya 6y ago> On the heels of the official LiveDashboard release, Phoenix 1.5 projects now ship with LiveDashboard by default, for real-time performance monitoring and debugging tools. and it uses uPlot [1][2] in the metrics panel :D [1] https://news.ycombinator.com/item?id=21207132 https://news.ycombinator.com/item?id=21207132 [2] https://news.ycombinator.com/item?id=22567922 https://news.ycombinator.com/item?id=22567922
- dangerboysteve 6y agoThe video is hilarious in a good way. You can hear the disbelief and amazement in Chris McCord's voice when Liveview works as he (and team) developed it.
- dyren 6y agoDisbelief might be a stretch, but he is clearly extremely excited about the recent advancements and proud of what the team has been able to accomplish. I agree that it's fun to witness that level of passion and it makes me happy that Chris is so amped about this.
- rozap 6y agoI wrote a little app recently to test out live-view. It was my first time really working with it, though I've been writing elixir for years. https://gif.energy https://gif.energy Didn't really have any issues. There were maybe one or two gotchas but they were explained clearly by the docs (appending vs updating elements) and I was able to get it sorted easily. That whole app took a couple days, but more than half the time was wasted on iOS not supporting mp4 and webm formats for the animated shots in the chat messages. Unfortunately, liveview does not fix Apple's stupid walled garden. Overall it was a great way to minimize the javascript involved. It doesn't make sense for certain types of apps, but it really adds a ton of value and saves a lot of time when the use case is right. And it performs really well. Loading and rendering a chatroom full of messages (with animated gifs in each message) makes a couple requests and happens in less than a second. And combined with phoenix presence it was like...5 lines of code to add realtime online/offline statuses for users. Super cool.
- ishwarn 6y ago> It doesn't make sense for certain types of apps, but it really adds a ton of value and saves a lot of time when the use case is right What are some of these use cases?
- 411111111111111 6y agoI'm not the person you asked this, but the BEAM (and phoenix by extension) excels in highly parallel contexts. basically if you got an application which wants to connect everyone to each other in real time, thats a perfect usecase for the BEAM. so chat rooms, live-feeds, comments, video/audio conferencing, etc. and thats also exactly where phoenix excels in my opinion as a occasional user. (never professionally though) quick and seamless communication between silly amounts of people with almost negligible amount of resources while being error tolerant to an extreme (functional, so almost no state) just try it out on a weekend. its definitely worth it just to see how web-development couldve been. you'll probably go back to the old way, because thats just how you earn your money and where you already have your expertise... but its definitely amazing to see how easy it can be
- 6y ago
- banashark 6y agoFor those wondering how this works under the hood, there is a great presentation: https://www.youtube.com/watch?v=9eOo8hSbMAc https://www.youtube.com/watch?v=9eOo8hSbMAc I wrote out a quick analysis of the details there along with some looking into the backing code in text format here: https://github.com/SaturnFramework/Saturn/issues/228#issuecomment-614317426 https://github.com/SaturnFramework/Saturn/issues/228#issueco...
- holtalanm 6y agoThis is pretty darn awesome. I remember looking at LiveView a few months ago and being impressed. Elixir and Phoenix are still my favorite backend to use for personal projects, but now with LiveView I'm thinking I'm going to start using it fullstack.
- AlchemistCamp 6y agoIt's so great to see this released. The community has been excited about LiveView for a long time!
- cvaidya1986 6y agoThis seems ideal for a social network idea I am cooking up. Is there a tutorial or course I can purchase like beginner to all the way to deployment on Digital Ocean or something like that ?
- fenwick67 6y agoFYI, Pleroma is a Mastodon clone written in Elixir with Phoenix, might be good to check it out. https://git.pleroma.social/pleroma/pleroma https://git.pleroma.social/pleroma/pleroma
- theagilecoder 6y agoElixir : https://pragprog.com/book/elixir16/programming-elixir-1-6 https://pragprog.com/book/elixir16/programming-elixir-1-6 Phoenix : https://pragprog.com/book/phoenix14/programming-phoenix-1-4 https://pragprog.com/book/phoenix14/programming-phoenix-1-4 Deployment : https://www.youtube.com/playlist?list=PLZZkJeUxu6QmO83Z1esRhp3lOeaNKZuXY https://www.youtube.com/playlist?list=PLZZkJeUxu6QmO83Z1esRh...
- cvaidya1986 6y agoThanks!
- brightball 6y agoThis is by far the most amazing demonstration of framework capability that I've ever seen. I'm stunned. HOW do you manage to broadcast only the minuscule change of a number to all of the connected clients with server side rendering? I'm trying to wrap my brain around it.
- nathan_long 6y agoChris McCord has given some talks and explained this - eg see https://www.youtube.com/watch?v=8xJzHq8ru0M https://www.youtube.com/watch?v=8xJzHq8ru0M at about 22 minutes in
- jakearmitage 6y agoHow would this scale for, I don't know, 10k concurrent users? Would a live chat app be reasonable?
- mercer 6y agoI'd say live chat and many concurrent users (+ many small messages being sent around) is exactly the kind of thing that Phoenix (and LiveView, and Elixir) is basically made for.
- AlchemistCamp 6y agoA live chat app is its sweet spot. It runs on the same Erlang VM that Whatsapp used to scale to hundreds of millions of users on under 30 machines and very few employees.
- jakearmitage 6y agoExcuse my lack of knowledge, but I was always under the impression that websockets are not that scalable since you are opening 1:1 connections.
- theagilecoder 6y agoThst not true in the Elixir ecosystem. The numbers I see on my 5$ droplet are sth I haven't seen before. And that after writing 5% of code that i usually had to write in other stacks.
- dorian-graph 6y agoHere's an example of using it with 2 millions users: https://www.youtube.com/watch?v=c6JcVwbOGXc https://www.youtube.com/watch?v=c6JcVwbOGXc
- pdr2020 6y agoI'm assuming the parent meant how would this specific configuration of elixir + phoenix + liveview scale.
- benja123 6y agoCongratulations Chris, Jose and the Phoenix core team on Phoenix 1.5 and the livedashboard. I used liveview in https://readastorytome.com https://readastorytome.com. I posted it here last week and it stayed on the front page for a good few hours. I was concerned about load, so before I posted it I upgraded my $5 DO box to a 4 core box which turned out to be completely unnecessary. The CPU load stayed in the 2-3% range the entire time it was on the front page, which is pretty amazing considering how much traffic was coming in. Funnily enough I came across the livedashboard repo just before I posted it, so I set it up and I was using it to monitor my app live while it was on the frontpage of HN. The dev experience is pretty amazing - I don't think I would have been able to write this app as quickly and to add new features at the pace I have been in any other language. So thank you Chris, Jose and the Phoenix/Elixir team. If anyone has questions about my experience with liveview free free to ask - either here or by email - ben@readastorytome.com
- julioo 6y agoWhat if you get disconnected due to bad network (LTE in transport). The reconnect will recover the state from the server or you loose everything ?
- josevalim 6y agoIt automatically reconnects. I wrote about the client/server state here: https://news.ycombinator.com/item?id=22897436 https://news.ycombinator.com/item?id=22897436 In a nutshell, temporary state in the client (URLs, forms) are resubmitted on reconnect. The server state is typically backed by a database.
- msie 6y agoI recommend this free Phoenix course: https://shankardevy.com/phoenix-inside-out-mpf/#mastering-phoenix-framework https://shankardevy.com/phoenix-inside-out-mpf/#mastering-ph... I found it more approachable than the PragProg book. Helps if you've dabbled in Rails a little bit.
- voppe 6y agoThis just keeps getting better and better. Thank you for your effort. I'm a big fan, Elixir + Phoenix is excellent enough, and LiveView is what really sealed the deal for me as the perfect web development stack. It's simple, it's fast, it works. Sure, it has a few rough spots that have to be worked around when you start to push its limits, but as this blog post showed it's perfect to quickly have a working web application by completely skipping having to write client-side code. I developed a couple of prototypes and single-use applications in hours that with any other stack would have taken me days. Hell, I'd argue that in some cases it took me less time to complete my app with LiveView than it would have taken me to setup Webpack with Frontend Framework. I don't believe it to be a silver bullet for sure, and it has to prove its worth at scale, but it gives excellent results with little effort, and honestly the reduced tedium is worth it on its own. Also, protip: try LiveView with Tailwind CSS.
- Pmop 6y agoI like the smell of new, well designed technologies.
- jakearmitage 6y agoWish they had an example on data tables, real-time search and other dashboard-like functionality.
- neillyons 6y agohttps://github.com/phoenixframework/phoenix_live_dashboard https://github.com/phoenixframework/phoenix_live_dashboard has tables and real time search.
- anthony_doan 6y agoI'm so happy. Just got back to my side project and Phoenix 1.5 is released. Thank you Chris and Jose and all those who were and are involve with Phoenix.
- overcast 6y agoLack of built in user authentication kills this project for me, that's just something I don't want to deal with building my own anymore after django.
- ahallock 6y agoNot built-in, but you look up several great projects for auth or use something like Auth0.
- chrismccord 6y agoWe are actually working on a `mix phx.gen.auth` generator. Check Dashbit's blog about it: https://dashbit.co/blog/a-new-authentication-solution-for-phoenix https://dashbit.co/blog/a-new-authentication-solution-for-ph...
- ihumanable 6y agoThe Phoenix Ecosystem has solutions for authentication and authorization. ueberauth is one of the most fully featured with support for a ton of different authentication schemes (https://github.com/ueberauth/ueberauth https://github.com/ueberauth/ueberauth) But there are lots of other things that integrate with Phoenix / Plug (https://github.com/h4cc/awesome-elixir#authentication https://github.com/h4cc/awesome-elixir#authentication)
- bostonvaulter2 6y agoPow is pretty great: https://powauth.com/ https://powauth.com/
- praveenperera 6y agoUse Pow: https://powauth.com/ https://powauth.com/
- PudgePacket 6y agoAnyone know where you'd get started with T&C's/PrivacyPolicy if you were actually taking something like this live?
- jamil7 6y agoI've been observing Elixir and Phoenix from the outside for 4 years or so now. There was a lot of initial hype and it died down a little bit but I'm really happy to see how far it's come and how polished everything looks. The lack of static typing initially made me pause but maybe it's time to get over it. As someone who tends to program in a functional style anyway (if a language supports it), losing the overhead of OO paradigms would not be a deal breaker and probably pretty liberating.
- swat535 6y agoThis is excellent and I’d love to look into this . That being said why would I pick this over go or scala for example ? I’m having a hard time finding a decent argument in the thread bedside syntax. Can someone elaborate?
- namelosw 6y agoWhat? It's anything but the syntax. The automatical live updates and the latency, the diff algorithm and the size of the payload, no client/api/controllers/routes needed, the scalability and stability, and the free clustering behind the framework. Can you rebuild this demo in Go or Scala in 15 mins or in 1 hour, correctly push any updates to the client while maintaining the robustness and sharding across the cluster? Writing stateful services correctly is very hard using an average web framework. I need at least 1 day to implement the same in Go or Scala, only the functionality but neither the clustering nor the optimization. And I'm considering I myself a functional programmer that is very familiar with Scala.
- namelosw 6y agoWhen I see a Phoenix post, I upvote. It's so great in terms of almost everything - simple, productive, powerful, and fast. If you're a web developer, go try it out if you haven't. I might be too greedy, but if there could be a solid JavaSript support Elixir/Phoenix just like ClojureScript that would be perfect. Phoenix and Liveview are great, but I really hope it can extend its reach to React Native and Electron so that we don't have to write too many extra things for those platforms.
- nathan_long 6y agoLumen may be the answer to this in the future: https://www.youtube.com/watch?v=uMgTIlgYB-U&list=PLqj39LCvnOWYTNs1n3ZNMSNO3Svv_XweT&index=3&t=0s https://www.youtube.com/watch?v=uMgTIlgYB-U&list=PLqj39LCvnO...
- namelosw 6y agoYeah, really looking forward to see this project keeps growing! I really hope we can use it in projects soon. Implementing runtime for Elixir in JavaScript is quite challenging IMO. Kudos for Dockyard trying to tackle this.
- showkhill 6y agoFantastic! For rails people who are unaware there is already a lib that has copied this approach. https://expo.stimulusreflex.com/demos/tabular https://expo.stimulusreflex.com/demos/tabular