javascript - Technique that allows a website to perform numerous simultaneous computations -


i developing website following:

  1. user can enter input, typically numbers.
  2. by clicking on button, website applies algorithm input. algorithm (a little bit) computationally intensive.
  3. the result of algorithm should shown on website user.

question: how 1 code kind of workflow efficiently - important me that...

  • ... computations performed fast possible user gets result fast possible.

  • ... web site can accessed lot of people @ same time without slowing each others computations down.

my own initial approach: have done research, didn't find the ideal solution. 1 option encountered in javascript on website, found javascript slow doesn't satisfy needs. describe current approach in following - if approach not best 1 please correct me , there no need spend time on approach - suggesting better approach far more useful me. current approach can described follows:

a.) after user enters input , clicks button, input data gets uploaded file on server. file should in same folder .html file web site. example: user can enter number , website doubles number user (a toy example of course). multiply.html code:

    <html>     <head></head>     <body>     enter number: <input type="text" id="numberfield">     <button type="button" id="doublebutton">double!</button>     </body>     </html> 

note: clicking button, entered number should written file "input.txt", functionality missing since didn't figure out how it...

b.) assume user input stored in file "input.txt". then, idea run program reads "input.txt", actual calculations , writes result file "output.txt". example continued: "input.txt" file contains single number "5" , nothing else. there c-program in same folder actual computation - in case doubling value of "5". there source file "program.c" code:

    #include <stdio.h>     #include <stdlib.h>      int main(int argc, char *argv[]){     file * fp;     int inputnumber;     fp = fopen("input.txt", "r");      fscanf(fp, "%d", &inputnumber);     file *f = fopen("output.txt", "w");     fprintf(f, "%d", 2*inputnumber);     fclose(f);     fclose(fp);     } 

c.) in third , last step, content of "output.txt" file - in example "10" - gets uploaded , shown somehow on website.

to summarize, there 2 issues have:

  1. what best technique achieve achieve a.),b.) , c.) such website responding , can accessed numerous users simultaneously?

  2. if own initial approach best technique, how can running? meaning hitting button on website downloads data, executes .c program, uploads output data , displays on website?

i know lot of content 1 question - hope make points clear. thank every , comment!


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -