NOAA-ORR-ERD / WebGnomeClient

Javascript client that uses the WebGnomeAPI to create and run py_gnome models.
3 stars 9 forks source link

Frequent require.js timeouts on front end initial load #4

Closed daf closed 9 years ago

daf commented 9 years ago

Running development on localhost, probably 1 out of 3 initial loads fail with console saying it's a require.js timeout. In staging/production that failure is basically 50% (maybe with network lag). Is there some sort of configurable parameter for this?

NaomiWilkins-NOAA commented 9 years ago

We've experience this too and the frequency seems to vary system to system (I hardly have it timeout but @alexmiranda-NOAA has it happen about as frequently as you).

For production the compiled version of the application should be used. grunt build will generate a dist/build/ folder with a build.html that is the application. I attempted to inline as many resources as possible with the build step but some third party libraries and fonts needed to be referenced externally so maintaining the structure of everything in the build folder is important.

There maybe some configuration parameter either in the node http server being used by the grunt serve/grunt develop commands or in the require config that would alleviate this but I haven't looked. We do have a development staging server using apache to serve the dynamic build and it hasn't timed out once, this leads me to believe the root of the problem might be node.

daf commented 9 years ago

Ok, I'll try the compiled version (grunt build) and see if that improves things - initial testing locally is definitely faster.

One wrinkle, would it be possible to maintain the config.json as a separate request somehow? It looks like it bakes it into the static site, which I agree is the normal flow, but separate would allow me to build a single docker image and deploy to staging and production (with separate configs). If not I'll have to build two images.

daf commented 9 years ago

Even better would be to be able to specify a config.json on disk while giving the grunt build command :)

daf commented 9 years ago

Figured out a workaround, see a diff here. Will close this as using the compiled version should solve perf issues. Thanks!

NaomiWilkins-NOAA commented 9 years ago

Interesting, so far we've always built on the production system. We hopefully will be working with something like docker eventually so we may follow your example here. Thank you for sharing!

daf commented 9 years ago

These changes aren't necessary to build a docker based version, but help when you want to deploy several with different configuration settings. I've added the Dockerfile to the gist (it's dirt simple).