I am trying to stream video from my webapp that is running on Tomcat7. The video stream is initiated by a HTML5 video tag which is also fed by the tomcat webapp. My solution so far is pretty straight forward. When a request for the video file comes to my HttpServletRequests doPost() I do some checks and then read the contents of the actual file and write them to the HttpServletResponse getOutputStream() using a read /write loop and a 64k buffer. The videos I am using for tests are in mp4 and ogv format and about 80mb in size.
It works fine in my test environment (local tomcat on ubuntu system) but does not on my web server. Unfortunately my server setup is a bit more complex and of course the networking is a bit slower than via localhost.. The server has an apache 2.2 as front end that basically does a bit of manipulation via mod_rewrite (redirecting most requests to https), does the tls processing and forwards the request to the tomcat via mod_jk/ajp13.
It seems stupid to stream video through tls but the rest of the site is tls. I tried to do the video request via plain http but then I am loosing my session information which I was wanting to use to restrict access to some of the video files to logged on users. It also did not seem to help the problem.
Using this setup the videos do not play and on several occasions the web server developed several apache processes going wild which sent the server into overload and basically finished it off (temporarily not available) until I restarted the tomcat.
My questions are as follows:
I have not gathered much information about video streaming to HTML5 but is it really as simple as writing the video file to the HttpServletResponse output stream?
My problem persists if I do not send the stream through tls (but still through mod_jk). Does it make any sense to send streaming data through tls? What might be the overhead ?
Has anyone got experience with streaming through mod_jk ? Does it make sense, are there special configuration requirements for streaming ?