Dart on AppEngine experiment 1 - avoid killer prices and use f1-micro instances
My first Dart AppEngine experiment doing a dummy HelloWorld turned out to be super expensive. Monitoring the project, 2 instances were always running, costing several bucks for doing...absolutely nothing...It seems that by default custom vm use a rather big instance.
Event worst, I was not able to stop these instances that kept restarting. The solution I ended up with was to upload a managed VMs (go in my case) dummy project instead where I could then make as the default and stop the previous instances in a proper way
I wanted to try running dart on a micro instance
Locally I managed to run my app using:
dev_appserver.py --custom_entrypoint "dart bin/server.dart --port {port}" app.yaml
and killing my app properly when needed using
pgrep -f dev_appserver.py | xargs kill -9
dev_appserver is actually detecting changes as I change my dart file and restart my server, however since it binds to the same port, it sometimes fails.
To deploy I can use the following app.yaml
runtime: custom vm: true api_version: 1
I want to deploy to my "tekartik-dev" project so I use
gcloud preview app deploy app.yaml --version tekartik-dev
The command being:
gcloud preview app deploy app.yaml --version
My helloword project (https://www.dartlang.org/server/google-cloud-platform/app-engine/run.html) is working, however it is not using a f1-micro instance. The solution is to add this in app.yaml
vm_settings: machine_type: f1-micro
This is now deprecated and according to https://groups.google.com/forum/#!topic/app-engine-managed-vms/2NNtkzeZm2U
so this can be used instead:
resources: cpu: 0.5 memory_gb: 0.10 disk_size_gb: 10
By default, there seems to be 2 instances running. you can reduce to one instance using
manual_scaling: instances: 1