Ideas for Performance Improvements
Hi, I came across this project recently and was quite intrigued. I looked through the code and it seems that currently, a docker container is created every time the user executes code. This is also done completely synchronously, blocking the entire thread.
It would probably be more scalable to spin up a fixed number of containers for each repository and run a network server on the container that will take requests, execute the command, and respond with the standard output. The downside is that this would require enabling the network in the container, but you could probably set up firewall rules in the container that block outbound connections.
I'm going to take a look at implementing this, but I'm currently having some difficulties getting the code to work on my computer.
Thanks for your interest and suggestion. I am glad you're looking at performance :-)
Would you please elaborate on the difficulties getting the code to work on your machine?
I think it's mainly due to incompatibilities with my version of docker. For one thing, the Python API is complaining that "network_disabled=True" is not a valid argument to create_container. I've taken that part out for now in order to get things working. Which versions of docker and docker-py are you using? Mine are 0.7.3 and 0.2.3 respectively.
Right now, I'm able to load the site OK, but I'm getting errors when running the Scheme code
error: (255)
*** Vicare: unhandled exception:
Condition components:
1. &lexical
2. &i/o-read
3. &message: "invalid syntax"
4. &irritants: (#\{)
5. &source-position:
port-id: "/home/runner/files/pre.txt"
byte: 816
character: 816
line: 12
column: 9
I tried printing out what "pre_input", "main_input", and "post_input" are supposed to be, and pre_input seems to be blank, so I'm puzzled at why this error is occurring.
Regarding docker versions, I am running 0.7.3 as well. For docker-py, I am using my own fork of master, which has the network_disabled option. I've sent a pull request for it, see https://github.com/dotcloud/docker-py/pull/133
The error with vicare is puzzling. Can you first try going to your host at the url /repl/webyrd/webmk?refresh=1 and try out the repl? Two other suggestions: (1) print the "url_pre" and visit that page, and see if you get something blank as you're supposed to; (2) since I am not deleting the images, and containers, perhaps you can also find out what the pre.txt files look like in the container/image.
Thanks!
I figured out the problem. I didn't have SERVER_NAME set, so the url wasn't being formed correctly. I've fixed it so that the correct URL is being passed in, but c.insert is timing out for some reason.
Oh, I see. What are you using for the SERVER_NAME, localhost:5000 or a "real" hostname? I've only tried it with real host names, even when developing, but I ought to make sure it works also locally.
Thanks!
I am using "localhost:5000" as my SERVER_NAME.
Thanks for the confirmation. I'll make sure I can run it with localhost, and ping you again. Thanks for your patience :)
I added the dev server-side installation steps here: https://github.com/namin/io.livecode.ch/blob/master/README.md#development-server-side-installation-steps
BTW, the timeout was because by default flask uses a single thread for development.
Thanks again! Let me know how things go :)
So I've realized that I don't really have the bandwidth to work on this right now. However, I've made a few commits on the runner branch of my fork to introduce a Go program that can take messages from a TCP socket and pipe them into the standard input of a command. It's pretty hacky and you probably want to clean it up before using it, but it gives an idea of how the process inside the container could be implemented. Also, I wrote it in Go mainly because you can just copy the executable into the container and run it without having to install an extra runtime.
Sure, no problem. I appreciate your input already. I'll take a look at what you did. Thanks very much!
commit 40a339ddddfe05c2f6f0fe4280146a09138527cc should partially address performance issues by using mounting instead of downloading to share data with the container. still no container re-use though.