0

I am building an application that plays opus audio files stored on a nas mounted on the application server. The application reads these files, and send them to the HTTP response output stream.

I am using spring-mvc and the web application runs on tomcat. I get the audio files using:

<mvc:resources mapping="/audios/**" location="file:/path/to/the/mounted/nas"/>

and I serve them in a <audio> tag.

Now I would like to make the application extremely reactive and multi user friendly. If I have 20 people playing many audio simultaneously, the system gets very slow and I do not know what is the best thing to do.

Could you please suggest me how to improve the application

Thanks

Amit.rk3
  • 2,417
  • 2
  • 10
  • 16
QGA
  • 3,114
  • 7
  • 39
  • 62
  • What is the performance of your nas? Have you tried playing 20 songs off of the nas directly and compared that to going over tomcat/http? – hofan41 Jul 07 '15 at 21:38
  • It is an HP server with 32 GB of ram 2.4 Ghz Xeon. The connection between the application server and the nas is over a 1 Gbit/s network – QGA Jul 08 '15 at 10:42

1 Answers1

1

You have to first investigate where is the actual delay happening. Is it in getting resource from file system from within the code, or it is because Tomcat is not able to withstand more load. To make sure it's not the code issue, you can log the code execution time and check if everything is fine there. Here is the way to do that - How do I time a method's execution in Java?

Now if it's the Tomcat server which is not able to withstand the load, which looks more probable issue, you might want to consider having cluster of multiple tomcat instances by creating a load balancer configuration with Apache web server. This way requests traffic load will be distributed by web server to all the running tomcat nodes, which will reduce the latency.

You can find how to configure load balancing at these link-

http://www.tutorialspoint.com/white-papers/load-balancing-and-scalability-via-tomcat-clusters.htm

https://tomcat.apache.org/connectors-doc/generic_howto/loadbalancers.html

Community
  • 1
  • 1
Amit.rk3
  • 2,417
  • 2
  • 10
  • 16
  • In your personal opinion is Tomcat the right chose for streaming?? To me it seems a good tool to to start from but from what I have read so far this seems quite limited. What do you think about Glassfish? Can you suggest other alternatives? – QGA Jul 07 '15 at 22:29
  • 1
    @QuentinTanioartino : I haven't used Glassfish. I have worked with Tomcat, WebLogic and Websphere. Regarding Tomcat you are right, it is very basic server and ideal for light weight applications and not suitable for large enterprise applications. Glassfish might be better option than Tomcat. – Amit.rk3 Jul 07 '15 at 22:36