Heroku R10 boot time error

I’m creating an app using Heroku and I’ve been having success deploying the site on a small scale. (I’m only using 5 or so pages in this small scale deploy for testing). I have about 30 different pages as a part of this app. They are all very similar but they have different data and color scheme. The functionality is the same across all of them.

The R10 boot time error issue happens when I try and deploy the app with all 30 pages. My index file is below. When I get the error I am trying to import all files. I believe I get R10 because my app can’t import all 30 pages in 60 seconds. If I wait to the files when they click on each link then the callbacks don’t work unless you refresh the page. That is kind of the method I’m doing in my current index file. However, the app does build and deploy very quickly. What are my options?

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import dash_bootstrap_components as dbc
from app import app
from app import server
from apps import pitch
from apps import first
from apps import bal
#from apps import nyy
#from apps import tbr
#from apps import bos
#from apps import tor
#from apps import mins
#from apps import cle
#from apps import chw
#from apps import kcr
#from apps import det
#from apps import hou
#from apps import oak
#from apps import tex
#from apps import laa
#from apps import sea
#from apps import atl
#from apps import wsn
#from apps import phi
#from apps import nym
#from apps import mia
#from apps import stl
#from apps import mil
#from apps import chc
#from apps import cin
#from apps import pit
#from apps import lad
#from apps import sdp
#from apps import sfg
#from apps import ari
#from apps import col

app.layout = html.Div([
    dcc.Location(id='url', refresh=False),
    html.Div(id='page-content')
])


@app.callback(Output('page-content', 'children'),
              [Input('url', 'pathname')])
def display_page(pathname):
    if pathname == '/first':
        return first.layout
    elif pathname == '/pitch':
        return pitch.layout
    elif pathname == '/bal':
        return bal()
    elif pathname == '/nyy':
        from apps import nyy
        return nyy()
    elif pathname == '/tbr':
        from apps import tbr
        return tbr.layout
    elif pathname == '/bos':
        from apps import bos
        return bos.layout
    elif pathname == '/tor':
        from apps import tor
        return tor.layout
    elif pathname == '/mins':
        from apps import mins
        return mins.layout
    elif pathname == '/cle':
        from apps import cle
        return cle.layout
    elif pathname == '/chw':
        from apps import chw
        return chw.layout
    elif pathname == '/kcr':
        from apps import kcr
        return kcr.layout
    elif pathname == '/det':
        return det.layout
    elif pathname == '/hou':
        return hou.layout
    elif pathname == '/oak':
        return oak.layout
    elif pathname == '/tex':
        return tex.layout
    elif pathname == '/laa':
        return laa.layout
    elif pathname == '/sea':
        return sea.layout
    elif pathname == '/atl':
        return atl.layout
    elif pathname == '/wsn':
        return wsn.layout
    elif pathname == '/phi':
        return phi.layout
    elif pathname == '/nym':
        return nym.layout
    elif pathname == '/mia':
        return mia.layout
    elif pathname == '/stl':
        return stl.layout
    elif pathname == '/mil':
        return mil.layout
    elif pathname == '/chc':
        return chc.layout
    elif pathname == '/cin':
        return cin.layout
    elif pathname == '/pit':
        return pit.layout
    elif pathname == '/lad':
        return lad.layout
    elif pathname == '/sdp':
        return sdp.layout
    elif pathname == '/sfg':
        return sfg.layout
    elif pathname == '/ari':
        return ari.layout
    elif pathname == '/col':
        return col.layout
    else:
        return first.layout


if __name__ == '__main__':
    app.run_server(debug=True)


My github is here and my website is here. Notice Baltimore Orioles (bal) in AL East works like I want it to, New York Yankees (nyy) does not. I’m using the import on start up with Baltimore and import on link click with New York.

This app runs locally but takes awhile to start up.

Any help or tips would be greatly appreciated!

Thanks

Wow. Can’t believe nobody bothers to answer these queries. Guess Heroku is irrelevant.

It honestly is… I found a lot of success with AWS free tier and it is only about $5 a month after the free tier is done.

For the record, I’ve never really fully understood port configuration between python, docker and heroku (which, in my case, would presumably apply to any hosting env) and this solved that problem for me:

to wit:

if __name__ == "__main__":
        # Bind to PORT if defined, otherwise default to 8051.
    port = int(os.environ.get('PORT', 8051))
    app.run_server(host='0.0.0.0', port=port)

And for the R15 (vastly exceeding memory) error, disabling initial callbacks was a workaround, if not a complete fix:

@app.callback(
    Output("graph", "figure"),
    Output('data-table', 'data'),
    Output('data-table', 'columns'),
    Output('range-slider', 'value'),
    [Input('operand_0', 'value'),
    Input('operator', 'value'),
    Input('operand_1', 'value'),
    Input('range-slider', 'value'),
    Input('day-slider', 'value'),
    Input('hour-slider', 'value')]
    ,prevent_initial_call=True
    )

Seems the callbacks are spiking memory, but I haven’t figured out a way to fix that. And still haven’t gotten caching/memoization going, though I think it might be a good idea to, if I can figure out how.

I’m checking out Linode now… https://login.linode.com/