Note: I originally thought to post this as a non-answer/extended comment to this question; however I feared that I would end up hijacking the original question. It is likely a duplicate with the exception that a specific example is provided.
With the effective death of the Wolfram CDF plugin, I am looking for alternatives to provide interactive (mainly through Manipulate
) content on my website. As an example, I would like to deploy m = Manipulate[Plot[Sin[a x], {x, 0, 10}], {a, 1, 10}]
. I'm currently using a free Wolfram Cloud account, which provides me with 12000 cloud credits per month. I watch those cloud credits with a simple dynamic plot:
$cca = Association[];
ccatask = CreateScheduledTask[$cca[Now] = $CloudCreditsAvailable, 5];
StartScheduledTask@ccatask;
Dynamic@DateListPlot@$cca
I created the CloudObject and the appropriate embed code with:
m = Manipulate[Plot[Sin[a x], {x, 0, 10}], {a, 1, 10}]
cd = CloudDeploy[m, Permissions -> "Public"]
EmbedCode[cd]
Over the course of approximately 4 minutes of testing this rather trivial interactive object, my $CloudCreditsAvailable
dropped about 150 points.
Below is a "real time" animated gif showing the responsiveness of this Manipulate
when run in animation mode alongside a plot counting my cloud credits.
The responsiveness of the deployed object is clearly terrible, and it appears that I am charged credits for each time a new value of the Manipulate iterator is passed to the cloud. Assuming that the responsiveness were acceptable, there is little chance that a deployed object with meaningful calculations even slightly more complex than this toy code would be usable by more than a few visitors to my website before my cloud credits were exhausted.
Question 1. What are some general guidelines for constructing efficient (in terms of cloud credits) interactive content deployed via the cloud?
Question 2. Since the lack of a plugin necessitates (at least as of right now) that computations be performed server-side, what are some design choices that can be implemented to reduce the need to contact the server and thereby improve responsiveness?
APIFunction
that randomly picks an account toHTTPRedirect
to. It's a bad solution, of course, but it could be automated and fix part of the problem. Of courseManipulate
crushes your credits so fast I don't think it'll help you here... I tend to just auto-exportManipulate
to GIF. $\endgroup$