oTree Forum >

Creating a new session in a room with Heroku takes up to 5 minutes ?

#1 by m_hr3


When I create a new session (using Heroku) in my room with 20+ participants my session configs take minutes to work - I just timed it and it was 3 minutes 40 seconds. In the admin window the room itself never stops 'configuring' however at some point the participants' pages do move on to the experiment. I then can access the session by just clicking away from the room and then going back.

I never noticed this issue before when testing with 3-15 participants, but now it's a big issue.

What could cause it to be so slow?

Thanks for any help or tips.

#2 by Chris_oTree

How many rounds? Also, can you show the code of any creating_session you have?

#3 by m_hr3

I have about 380 rounds, and I have this same creating_session for 4 apps:

def creating_session(subsession):
    session = subsession.session
    for player in subsession.get_players(): #create the tie budget variable to Rougeuce from it when SL buy ties
        session = subsession.session
        players = subsession.get_players()
        matrix = session.matrix
        participant = player.participant
        participant.N4tie_budget = Constants.tie_budget
        if player.id_in_group in session.demonstrators:
            participant.type = 'IL'
            player.type = participant.type
            participant.type = 'SL'
            player.type = participant.type
    if subsession.round_number == 1:
        for group in subsession.get_groups(): #get the list of True and False that indicate if Rouge (true) or Bleu (false) is the
            #highest payoff choice for the round.
            list_best_option_for_block = ([True, False])
            bestchoices = list(random.choices(list_best_option_for_block, k=5))
            session.N4best = bestchoices #save the list, which is the same for all participants, in the session var
    if subsession.round_number == 1:
            for player in subsession.get_players():
                participant = player.participant
                copy_tie_choice_order = Constants.tie_choice_order.copy()
                random_list_order = random.sample(copy_tie_choice_order, k=len(copy_tie_choice_order))
                participant.N4tie_choices_treatment = random_list_order
                if participant.type == 'SL':
                    participant.N4_choice_condition_1 = participant.N4tie_choices_treatment[0]
                    participant.N4_choice_condition_2 = participant.N4tie_choices_treatment[1]
                    participant.N4_choice_condition_3 = participant.N4tie_choices_treatment[2]
                    participant.N4_choice_condition_4 = participant.N4tie_choices_treatment[3]
                    participant.N4_choice_condition_5 = participant.N4tie_choices_treatment[4]

#4 by Chris_oTree

That code contains nested loops. you should get rid of them.

#5 by Chris_oTree

Actually what I really mean is that you have a nested call to subsession methods like .get_players() and .set_group_matrix() inside a for loop. they should be outside the for loop. you only need to do them once.

#6 by m_hr3

Hi, thanks a lot for your response. I didn't have a chance to fix it yet but something I also noticed now is each deployment takes longer and longer - first one was 3 min, and now a fifth one took 11 minutes. Can this be an issue with not having bought powerful enough Heroku applications? Thanks a lot!!

#7 by Chris_oTree

It should be done within seconds. Check the Heroku status page. There was a forum post about it yesterday.

Write a reply

Set forum username