Open amitaibu opened 7 years ago
@amitaibu Exciting :), what would the the priority of this task?
Up and running everything on localhost:
For the sake of my curiosity, just made a bid POSTing quick benchmark:
About the deployment part, I'd envision something like this: Docker-compose on host virtual machine, that uses the following images:
Start to play with these on localhost.
Now I realize that we don't need any Haskell / Yesod thing on the production, we need the:
And that's all. Trying it out on a temporary VPS, for now without Docker.
On the VPS, the app can be started, it only fails due to the lack of MySQL. Ubuntu 16.04.2, the only extra package is libpq5
root@localhost:~# ./circuit-yesod
circuit-yesod: libpq: failed (could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
)
it only fails due to the lack of MySQL
we in fact use postgres
just made a bid POSTing quick benchmark:
24ms for POST and 12ms for GET is nice, isn't it? 😜
The benchmark is nice, however we're in almost the same order of magnitude with PHP7. However for sure we can expect much better scalability here, possibly multithreaded app out of the box (?).
Yes, it's postgres, i just use MySQL too many places :)
Dockerized Postgres is used by the yet not Dockerized app on the VPS:
Temporarily http://172.104.150.92:3000 hosts the app:
Both the DB and the app is in Docker (at the DB, without persistency considerations for now)
Somehow the app tries to connect to localhost, @amitaibu , dist/config/settings.yml
should hold the config normally, right?
I would guess so, but haven't executed a built app. I've always used stack exec -- yesod devel
(you can set via variable export APPROOT=https://example.com
)
The solution was that I need to edit the configfile before stack build
, it's somehow compiled in.
Now DB + Yesod app is nicely working in the container. Still have 2 hours left from the issue, playing with the loadbalancer in front of the app.
it's somehow compiled in.
That's part of the hot sauce of Yesod -- you get compiler validations on your settings (even on your css files!)
We have a smooth mix of Nginx loadbalancer, Yesod servers (3 of them) and Postgresql.
The app is available via http://172.104.150.92/ (i will leave it like this for a day or so). We have 0.5 hours remaining.
Actually there could be several improvements and fixes to think of:
deploy/package.sh
, which is needed for the Docker image compilationnice!
In order to allow login in debug mode could you set debug to true?
Actually there could be several improvements and fixes to think of:
As follow ups? If so, can you open the issue(s) and timebox them as you see fit.
Re-deployed with debug mode, login is now possible. Yes, we can think about it as follow-ups, however the work is not fully self-contained here. In the remaining 0.5 hours, i try to make the last point, to make sure all the steps are automated. And going to create the follow-up issues for sure.
If you'd like to bump this issue in 2-3h (?) and address them here that also possible.
Thanks! Sounds better for me, webapp DB without persistency is not something ready, that's for sure :)
btw @AronNovak is this an ec server? Can we Blazemeter it to see how scalable it is?
@amitaibu No, it's a Linode VPS on my personal account, I don't like EC2 too much either, and we did not arrange Google Cloud access, so i solved it that way, as anyways it should be disposable.
And certainly we can do scalability tests, why not with Blazemeter.
I've added you to a Google cloud project
Thanks!
@amitaibu
Could you advise me how to access that?
Just tested, related to sessions, it's absolutely not an issue to have the loadbalancer, not sure how the session handling of the app works exactly, but had a session where /profile
was served by different backends and the login remained persistent.
Just rolled out a new version (just changed the copyright) of the app with zero downtime:
root@localhost:~/deploy/deploy# docker build -t circuit .
Sending build context to Docker daemon 249.3 MB
Step 1/5 : FROM ubuntu:16.04
---> 6a2f32de169d
Step 2/5 : RUN apt-get -y update && apt-get install -y libpq5
---> Using cache
---> 28d61589b2ed
Step 3/5 : WORKDIR /var/www
---> Using cache
---> 9123112b7064
Step 4/5 : ADD . /var/www
docker images ---> 48f77f4cdb20
Removing intermediate container 7a8b142d2ac4
Step 5/5 : CMD sleep 10 && cd /var/www/dist/ && /var/www/dist/circuit-yesod
---> Running in e4513b611f4c
---> 5862d3412186
Removing intermediate container e4513b611f4c
Successfully built 5862d3412186
root@localhost:~/deploy/deploy# docker-compose stop circuit_2
Stopping deploy_circuit_2_1 ... done
root@localhost:~/deploy/deploy# docker-compose stop circuit_1
Stopping deploy_circuit_1_1 ... done
root@localhost:~/deploy/deploy# docker-compose up -d --no-deps circuit_1
Recreating deploy_circuit_1_1
root@localhost:~/deploy/deploy# docker-compose up -d --no-deps circuit_2
Recreating deploy_circuit_2_1
root@localhost:~/deploy/deploy# docker-compose stop circuit_0
Stopping deploy_circuit_0_1 ... done
root@localhost:~/deploy/deploy# docker-compose up -d --no-deps circuit_0
Recreating deploy_circuit_0_1
root@localhost:~/deploy/deploy# ls
dist docker-compose.yml Dockerfile nohup.out package.sh
root@localhost:~/deploy/deploy#
Adding README.md for the initial and the further deployments.
Now what was done in the PR is self-contained, all the points from https://github.com/Gizra/circuit-yesod/issues/31#issuecomment-293881137 are addressed, at least in a basic way.
There's Keter, but maybe a better approach would be to use Docker (see example) and have a load balancer infront of it, so we can switch on and off instances.
@AronNovak this is definitely a task under your domain 😉