-->
Page 1 of 2

Best method for creating a fast HTTP server

PostPosted: Thu Apr 09, 2015 10:01 pm
by Jasper np
Hey!

I just received my first ESP8266 module and I am looking for some guidance and suggestions on the best way to make a fast webserver out this ESP8266 which is able to serve up HTML pages of 5000 > 6000 characters as quickly as possible.

I know of at least 3 conceptual methods to do this
- Write a webserver application and flash it to the ESP8266 using its DEV tools
- Write the webserver on an Arduino board and send all commands to the ESp8266 via Serial
- Write the webserver application in the new Arduino ESP8266 IDE release

I made a working webserver last night using the new Arduino IDE EPS8266 edition (since I am already quite familiar with writing arduino network application) however using the "client.print()" function to send my stylesheet and webpage to my browser takes around 10 seconds!


I could probably reduce this time by reducing the amount of client.print() calls (I use quite a few in order to keep the HTML code somewhat readable...)..which I will be testing tonight. Does anyone know the optimal amount of characters to include in each client.print() call with the wifi library? Is there a faster way to send data to the connected client?


But am I running up hill here? Will this method of programming the ESP8266 ever be able to provide a FAST web browsing experience with HTML pages of up to 6000 characters?

Note that no images are required on the webpages.

Any thoughts and suggestions would be fantastic !

Re: Best method for creating a fast HTTP server

PostPosted: Fri Apr 10, 2015 5:48 am
by bjpirt
I'd use esp-httpd - I find it pretty quick for my needs, but you can always flash on the default files and time them loading in your browser.

It's definitely the closest to the metal solution if speed is what you're after.

Re: Best method for creating a fast HTTP server

PostPosted: Fri Apr 10, 2015 8:23 am
by Jasper np
Thanks I will take a look at that perhaps...

However I have done further testing tonight ever using the Arduino ESP8266 IDE with good results which should be noted down for anyone looking to serve up webpages using client.print("") int he arduino IDE with ESP8266.

I have managed to reduce my page load to around 4-5seconds (acceptable for what im doing) down from about 12seconds just by reducing the amount of client.print() commands used to server up the web page in chunks of HTML

Observations and notes
- Each client.print() command seems to cost about 300ms regardless of the length of data you are sending!
- Each client.print() command is good for up to 300 characters before the sketch fails to compile!
- You may need to include a few client.println() commands after a few hundred lines of code or else it wont render in iPhone/ipads for some reason.

Re: Best method for creating a fast HTTP server

PostPosted: Fri Apr 10, 2015 2:38 pm
by lethe
Jasper np wrote: - Each client.print() command seems to cost about 300ms regardless of the length of data you are sending!
- Each client.print() command is good for up to 300 characters before the sketch fails to compile!
- You may need to include a few client.println() commands after a few hundred lines of code or else it wont render in iPhone/ipads for some reason.

If those onservations are accurate, that would amount to a transmission rate of less than 1KB/s, which is pretty terrible. There has to be a more efficient way to send data with the Arduino IDE (if everything else fails, you can probably invoke SDK API directly).

Just out of curiosity, I timed loading the index page of my esphttd based project: Image
The comparion might not be fair though, since most of it is static content (only index.tpl has a few placeholders that are replaced at runtime).