You’re not receiving notifications from this thread.
GoRails Performance - The Techniques I Use Discussion
Hey Pete, this usually happens from one of two things:
1. You're using a third party library (like Segment.io for example) that isn't compatible with Turbolinks events by default. These usually require some tweaking in order to make compatible. It all depends on the library but there are usually ways to do it. You can google for that library + turbolinks and see if anyone else has made it work, or if you can tweak it yourself.
2. Sometimes it can just be a simple setup issue if your JS is running incorrectly. Maybe you need the jQuery.turbolinks adapter, or just to modify your code slightly to allow running on multiple pages.
It all kinda depends on your code and the issues you're experiencing. They can be kinda hard to track down so the easy solution is to turn off turbolinks for those links in the meantime if you can figure it out. I don't think there's anything wrong with that so you can figure it out later.
Hey Chris, thanks for getting back to me.
Well mostly the problem is with external libraries to be honest. Guess data-no-turbolink seems easier than trying to find a solution each time. But maybe its high time i do that.
Great insight! Though now I'm really hoping you'll do another video on how to implement and get the best out of Turbolinks. Few resources out there and you did a good job with the marketing :D
I definitely will. I also need to learn some around Swift and Android so that I can make some example apps using the Turbolinks adapters. That might mean we'll have a GoRails mobile app at some point. :)
Why not React Native? It will save you a lot of time. Or you can wait a year or so. Google plans to ditch Java in favor of Swift for Android development.
Mostly because I'd rather spend most of my time doing the heavy lifting in Rails rather than JS. If you built your Rails frontend in React already, React native is the way to go. Since I'm using Turbolinks already and because I don't have any complex JS widgets on the frontend to need React, the Turbolinks adapters are the best solution for me. React could just as easily fill the same gaps, just fits well for me.
With Turbolinks on mobile, you get a web view that embeds the Rails site just like you would have in your browser, but you can override link clicks with native code. So all the stuff you see on mobile is just as if you were viewing it in the browser. It's a hybrid app because of the webview, but easily intercepts those things to do native Swift or whatever. Turbolinks would only need the server to return HTML and so you don't really need to build an API.
React Native is somewhat similar in that you're still sharing the same app code with the main website, but you will have to build an API to make React work, and you'll need to do some extra work to serve up the HTML as well.
I didn't know it's possible to have a mobile app without building an API. That's good to know.
Give their readme a look on the new iOS adapter. It might help wrap your head around it a bit. https://github.com/turbolin...
Basically your mobile app just ends up primarily being a WebView (webkit browser full screen) and it let's you set the website. This is similar to things like PhoneGap in the past, except that the code is all just your public website meaning you can update your mobile app at any time by deploying your website again. Pretty slick! I'm not sure if React Native lets you do things like that.
Another suggestion is a non-rails issue, but fundamental nonetheless: focus on the database queries themselves. A great suggestion I have held dear over the years is to ask "what are the critical queries an application may have?" (the most frequent one, the most valuable, the most calculation intense...) On that basis, with a knowledge of how databases index, one can often find a data structure that is more efficient than another (conception over optimisation). Large test data sets for different data structures allow to validate design choices. To me, that is the core of the onion...
Chris, any chance you could go into detail about how to set up nginx and passenger to properly utilize the resources of your server? I follow your guides when installing so no fine tuning is ever done to my servers. Also would love to see how to set up redis for caching.
Thanks Chris. I would love to see how you make improvements on all the external API calls for getting data from different services.
im in the Video yay lol Chris keep up the good work
Does your 2GB droplet contain your entire stack (db/cache/nginx/passenger) or did you break out the db/cache?
I would love to watch a serie , instead of a bunch of randoms episodes, something like laracasts but for rails..... A lot of people will pay for that
Question, maybe to clarify some things, if you can, please answer, thanks.
Why did you choose digitalocean over heroku?
PD: Im thinking about changing to digitalocean because in heroku every add-on in production mode is paid, and if you have few your are going to paid 3x times more than having a digitalocean($20). But i not sure if i'll make the right things in digitalocean.
I’m watching this for the first time now (in 2021) and it’s awesome to see how spot on Chris is with his use and recommendation of Turbolinks.
Very helpfull as always, thanks Chris!
- What would happen in the hypothetical "exaggerated" case of upgrading the Digital Ocean plan to, say, 256GB of memory. All other things being equal, would this fix the loading speed and overall site performance without the need to optimize the frontend, assets or cache?
More RAM would help you run more Rails processes at once so you could serve more users at once, but each individual request will still need to be optimized to run as quick as possible. Caching & optimizing assets is still important and a bigger CPU can help process requests slightly faster.