eileennoonan

eileennoonan

FLAME slow cold starts

I’m deploying an app on Fly.io, and it’s going to involve running headless browsers similarly to World Page Speed. So naturally I’d like to use FLAME to manage the headless browser portion.

The problem is my FLAME nodes have very long cold starts - upwards of 20 seconds even when I boost the machine resources.

I am assuming that this is because I have so many dependencies in my main app - Phoenix, Nx, and Ash + a bunch of Ash extensions are probably the main contenders.

Is that assumption correct?

If so, would it make sense to just create a separate mix app for my headless browser FLAME calls? I think just about the only dependency it would need to boot would be web_driver_client and req. No Ash, no Phoenix. And I see that with FLAME.FlyBackend we can specify which docker image we want our node to spin up.

Is this a normal / recommended way of using FLAME? Any tips before I head down that road? It seems like I might not even need to write any code in the headless browser runner app, just make sure the correct dependencies are loaded.

~Eileen Noonan

Marked As Solved

chrismccord

chrismccord

Creator of Phoenix

What is the size of your app image? What region(s) is your app located? There’s nothing to compile/build since it will be launching the prebuilt docker image from the parent. Are you certain the time is the cold start and not something app specific like the time to load your headless chromedriver process and start your sup tree? worldpagespeed cold starts are in the 5-10s range with the time including actual time to start chrome/chromedriver and start driving the browser. Are you consistently seeing these times or only occasionally? Depending on machine placement, the docker image layers may need to be pulled to a new host, so that can also add time and the size of the image would affect that, but we need to know more. Your fly logs would also be reporting the image pull time.

You can also look into starting with a warm pool min: whatever and min_idle_shutdown_after to idle down below min if no work is needed to avoid deploys causing users to hit a cold pool.

Also Liked

jswanner

jswanner

Welcome Eileen! We met at ElixirConf, good to see you on the forum.

I’ve haven’t used FLAME yet, so I don’t know if there are recommended ways to handle your situation and I’m not speaking from experience. If I were in your position, I would start by modifying the MyApp.Application.start/2 callback (lib/my_app/application.ex) to conditionally specify what should start when run via FLAME or not. FLAME.Parent.get/0 can be used to determine which way the application is being started.

josevalim

josevalim

Creator of Elixir

If you are concerned about the boot time on the number of dependencies, maybe setting RELEASE_MODE=interactive as an env var will help loading less code? You should also consider trimming your Application.start supervision tree.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

We're in Beta

About us Mission Statement