Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-36229

Low performance at uploading html5 recorded audio


    • Type: Bug
    • Status: CLOSED
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 10.7, 11.0, 12.0
    • Fix Version/s: 11.0
    • Labels:
    • Environment:
      Issue on server. Tested on Centos 6.7,Tomcat 7.0.62, Oracle Jdk 1.7.0_79-b15 64b
    • 11 status:
    • Previous Issue Keys:
    • Test Plan:

      Create a quizz with an audio question of 180 seconds length.
      Record it with the html5 audio recorder and save.

      Create a quizz with an audio question of 180 seconds length. Record it with the html5 audio recorder and save.


      We have found a very low perfomance at uploading audio files captured with htlm5 recorder, having the save to db disabled. Even without
      saving the blob to db the performance was very poor and just an small set of students collapsed the cpu at server.

      We observed that after the file was correctly saved at filesystem it took to sakai a lot of time (30secs or more) to acknowledge to user the uploading to fliesystem is done. During that time the cpu load increased a lot without some logical reason as the actual file uploading had finished long ago.

      After some investigation to track down the issue, we have found that even without the need of saving the file as blob in db it is processed enterely in a not very efficient way, instead of just getting the size and location.


         // 1. create a media record
          File media = new File(mediaLocation);
          byte[] mediaByte = getMediaStream(mediaLocation);   -> *(problem/improvement needed): read the entire file byte by byte, not needed if no blob is required*
          log.debug("**** SAVETODB=" + SAVETODB);
          MediaData mediaData = null;
          if (SAVETODB)
          { // put the byte[] in
            mediaData = new MediaData(itemGrading, mediaByte,
                                      Long.valueOf(mediaByte.length + ""),
                                      mimeType, "description", null,
                                      media.getName(), false, false, Integer.valueOf(1),
                                      agent, new Date(),
                                      agent, new Date(), duration);
          { // put the location in
            mediaData = new MediaData(itemGrading, null,
                                      Long.valueOf(mediaByte.length + ""),
                                      mimeType, "description", mediaLocation,
                                      media.getName(), false, false,Integer.valueOf(1),
                                      agent, new Date(),
                                      agent, new Date(), duration);

      getMediaStream's performance is very low, it tooks abot 30 seconds to put a 30 MB file in the array (a 3min audio file). getMediaStream is called always, even when not saving as blob to db.

      Performance at getMediaStream can be easily increased using something like:

       array = Files.readAllBytes(new File(file).toPath()) --- from java.nio.file.Files

      It could also improved if the file is only enterely read (to array) when save to blob is needed and just getting the size when not from filesystem methods.

      The same happens in samigo\samigo-app\src\java\org\sakaiproject\tool\assessment\ui\bean\delivery\DeliveryBean.java

        Gliffy Diagrams



              Issue Links



                  ncaidin Neal Caidin
                  javier.carrillo Javier Carrillo
                  1 Vote for this issue
                  3 Start watching this issue



                      Git Integration