oTree Forum >

oTree on Google App Engine (GAE)

#1 by yshimod

Salesforce has announced that it will no longer offer free usage slots on Heroku.
As a result, we may no longer have a reason to choose Heroku.

I am considering using Google App Engine (GAE) as an alternative.
Please let me know if you know how to deploy an oTree app with GAE.
I expect I need to set "otree prodserver" as the "entrypoint" in app.yaml, but it seems difficult to configure for Postgres.

#2 by Chris_oTree

Hi, although it's worth considering GAE, keep in mind that next month Heroku will make announcements about free Heroku resources available to academic users (it was mentioned in today's announcement). Another possibility is that due to the many Heroku users protesting this change, Heroku might change/delay/scale back their plans, etc. Personally I am taking a "wait and see" approach.

#3 by yshimod

Thank you for your reply.

>free Heroku resources available to academic users (it was mentioned in today's announcement)
I had missed this comment.

However, it may be worthwhile to consider using GAE (not in a hurry), as it seems important to have other options besides Heroku.


Best,

#4 by yshimod

If we move over from Heroku, render.com may be much better than GAE.
I have successfully deployed it effortlessly with render.com.

#5 by jkupb

@yshimod

Can you share your experience with render? What is different from heroku?

#6 by yshimod

@jkupb

I have not yet used Render.com for my research, so I don't have enough experience with it.

I used to charge Heroku when conducting experiments for my research, and I will also charge Render.com for data collection.
Comparing the billing menus, Render.com has a more segmented pricing menu.
For non-commercial users, unless we conduct a large-scale experiment, limited service is enough.
Render.com's segmented pricing allows us at a lower cost.

Deployment operations seem to be similar to Heroku.

We can choose the server location from Singapore as well as US and Germany.
Having a choice of Singapore is an advantage for me living in Japan.

Short instructions on how to deploy
(1) Upload (push) the oTree project to your GitHub repository.
E.g., https://github.com/yshimod/otree_survey
Procfile and runtime.txt are not needed for Render.com, although they are needed for deployment on Heroku.
On the other hand, requirements.txt is required for Render.com.
(2) (Optional) Create a PostgreSQL instance in advance on Render.com and copy the "Internan Database URL".
(3) Create a new "Web Service" on Render.com, connect your GitHub account to Render.com, and select your repository.
(4) Set up your deployment as follows:
- Environment: "Python 3"
- Build Command: "pip install -r requirements.txt"
- Start Command: "otree prodserver"
- Advanced -> environment variables:
    - PYTHON_VERSION: "3.9.13" (for example)
    - OTREE_ADMIN_PASSWORD: "yourpassword"
    - OTREE_AUTH_LEVEL: "STUDY"
    - OTREE_PRODUCTION: "1"
    - DATABASE_URL: "postgres://**********" (the URL string you memorized in step (2))
(5) Click the "Create Web Service" button to start deployment.
Comparing Render.com's free plan with Heroku's, you can feel that Render.com takes longer.

#7 by jkupb

Thanks a lot @yshimod I will save your post for later.

In case that Heroku does not offer a good solution for students / researchers I think that the oTree documentation should include alternatives like this @Chris_oTree

#8 by Victor

I think it's great to have other solutions besides Heroku. I do have a note for European researchers. The most critical factor for them will be what their academic institution prefers. In many cases, those institutions will have data protection agreements (DPA) with a third party in place or they will have server capacity for you in-house. It is quite critical to check with your IT department and data protection officer to see what they cleared if you are in Europe.

In some cases, your institution will be flexible enough to set up a new DPA for you. My institution successfully set one up with Salesforce, the company behind Heroku (somewhat to my surprise because it is a US company). Together with the DPA, they also set up a "heroku enterprise account," including dedicated groups for the different departments here. I wrote about it here: https://www.otreehub.com/forum/127/.

#9 by RuRg92

Dear all, 

on render how to access the console as we used to on heroku by clicking run_console from the dashboard menu?
Specifically, i need to input the following command otree resetdb as i see the following error when opening the app 
Your database is not ready. Try resetting the database

#10 by sergio_sapina (edited )

RuRg92 Not sure if this is the optimal solution but I had the same issue and solved it by modifying "Settings > Build & Deploy > Start Command" to "otree resetdb --noinput & otree prodserver".

This way the database is destroyed and restarted before rebuilding the app.

Remember to change it back to just "otree prodserver" after you have finished modifying the database because I suspect that this is ran every time the app is awakened after the 15 minutes of inactivity, wiping any active sessions. I am not 100% sure of this and it may happen only with the free plan. I would appreciate if anyone could confirm this.

#11 by RuRg92

Thank you sergio_sapina

I also tried by installing the postgres and add the environmental variable again.
What is more troublesome onrender (at least so far for me) that when creating a session in prod, if nothing takes place after a while render closes the session. So you lose everything before that all the potential participant complete the experiment.
Does anyone know how to stop render from quitting the server? (with heroku again i never had this issue)

Best,

Ruggiero

#12 by sergio_sapina (edited )

Hi RuRg92,
What do you mean by Render closing the session? I have a session created 18h ago and it is still there, with around 8h of inactivity. How much time did you wait for the session to be removed?
Did you change the Start Command to "otree resetdb --noinput & otree prodserver"? If you did, change it back to "otree prodserver" after you have finished testing. I think that this gets ran every time Render awakes.
As far as I know, with your solution alone this should not happen but, if it still does, I am interested in the details to try to find a solution.

Best,
Sergio.

#13 by RuRg92

basically after 15 mins i lose all the session i created (either with demo or through rooms). I have my build command as otree prodsever.

Still can't figure out why this's happening but seems that if the app is sleeping render erases the db

Best,

Ruggiero

#14 by sergio_sapina

This is really puzzling me. Demo sessions delete themselves after a while so that's normal. But Rooms should create persistent sessions so this does not match what I am experiencing (I have a session almost 24h old that went into sleep multiple times).
Could you try to create persistent session without using the room feature and check if it gets deleted?
Do you have the app in production mode? Environment variables "OTREE_AUTH_LEVEL = STUDY" and "OTREE_PRODUCTION = 1"

Best,
Sergio.

#15 by RuRg92

Thank you Sergio.

I missed  "OTREE_AUTH_LEVEL = STUDY" but had "OTREE_PRODUCTION = 1"
I am trying now multiple attempt to see what happens. I will keep the community updated.

Rugg

#16 by RuRg92

Update:

I reinstall the database and add the suggested env.variables. Everything works fine now (no db reset, and no previous session loss). 

Though, render very slow compared to heroku. I wonder if anyone who tried Google App Engine (GAE) can tell us if is faster compared to.


Best,

RR

#17 by sergio_sapina

Thanks for the confirmation RuRg92.

I still have not tried Render past the free version so I am not sure how will it perform. I would also appreciate if someone shared any experience with actual experiments using Render or any other similar host site.

Write a reply

Set forum username