cancel
Showing results for 
Search instead for 
Did you mean: 

Writing contents to a node takes very long time

santosh
Champ in-the-making
Champ in-the-making
Hi,

I am trying to create a new content node and writing data from a file which is arond 2 MB size.
While testing I found that WebServiceFactory.getContentService().write() call takes around 10 sec to return.


The code I am using is as follows.
I have added the System.out to get the timimgs of each call.

    public static String createDocument (String folderPath, String documentName, ByteArrayInputStream bis) throws Exception {
        System.out.println("AlfrescoService.createDocument()");
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 1");
        ResultSetRow node = queryNode(folderPath);
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 2");
        Reference reference = new Reference(STORE, node.getNode().getId(), null);
        byte[] bytes = new byte[bis.available()];
        bis.read(bytes);

        String qName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, documentName);
        ParentReference parentReference = new ParentReference(reference.getStore(), reference.getUuid(),
                null, ASSOC_CHILDREN, qName);
        NamedValue[] properties = new NamedValue[]{new NamedValue(Constants.PROP_NAME, documentName)};
        CMLCreate create = new CMLCreate("1", parentReference, Constants.TYPE_CONTENT, properties);
        CML cml = new CML();
        cml.setCreate(new CMLCreate[]{create});
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 3");
        UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 4");
        if(result == null || result.length == 0) {
            throw new RuntimeException("Error creating the node at path <" + folderPath + '/' + documentName + '>');
        }
       
        // Get the created node and create the format
        Reference newDocumentNode = result[0].getDestination();  
        ContentFormat format = new ContentFormat("application/octet-stream", "UTF-8"); 
       
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 5");
        // Write the content
        WebServiceFactory.getContentService().write(newDocumentNode, Constants.PROP_CONTENT, bytes, format);
        System.out.println(new Timestamp(System.currentTimeMillis()) + " ## 6");
        System.out.println("AlfrescoService.createDocument()");
        return newDocumentNode.getUuid();
    }


I am using Mysql database. Is there any way I could use file persistence as it could improve the performance.

Thanks in advance,

Santosh
9 REPLIES 9

kevinr
Star Contributor
Star Contributor
File content in Alfresco is already stored on the filesystem - only meta-data is stored in the database. This suggests you have a different problem! Do normal network transfers happen quickly with other programs? 10sec for a 2MB file sounds very high indeed. We'll try a default Alfresco setup here and profile it to check that it's not some issue with the web-services API, but it would be great if you can check that it's nothing wierd on your setup also (are you saving content to network drives? Are the files being virus scanned all the time? - that kind of thing…)

Thanks,

Kevin

santosh
Champ in-the-making
Champ in-the-making
Hi,

I don't have issues with antivirus or file scanning.
I would check my environment once again and get back to you.

Thanks and regards,

Santosh

sergio
Champ in-the-making
Champ in-the-making
Hi all.

The same problem with upload/write a file to the repository. Alfresco spends too much time to complete the task.

In addition, I am running Alfresco on my pc, so I am sure I don't have any network problem.

Any suggestion?

Best regards,

Sergio

benjamin_doughe
Champ in-the-making
Champ in-the-making
Was this ever resolved?

I am getting long update/write times when using the webservices api.

Thanks,
Ben.

sergio
Champ in-the-making
Champ in-the-making
No, unfortunately.

The Alfresco team did not give any clear answer for this problem.

marcosvasousa
Champ in-the-making
Champ in-the-making
I have same issue in production envirorment.
Line "UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);" is very slow on first creation of document.

mrogers
Star Contributor
Star Contributor
As with the beginnings of this thread, there's not enough information to diagnose a problem, either in your recent posting or earlier.

Writing content is normally a fast operation since its relatively simple.    There could be a problem writing to disk, for example the disk is remote over a slow network or perhaps it is nearing being full,  disks struggle as they run out of room.   Next problem is lack of ram or other resource on the alfresco server.    SOAP web services are prone to RAM problems due to the need to keep everything in memory.    Next problem is a slow connection to alfresco.

That said one of the features of alfresco 4 is to remove indexing from transaction, which will speed up uploads.   (But it won't account for 10 seconds). 

Its also worth mentioning that these "old" web services are deprecated with CMIS being the preferred web service interface.

marcosvasousa
Champ in-the-making
Champ in-the-making
Please see https://forums.alfresco.com/en/viewtopic.php?f=45&t=47292&p=141265#p141265
There is detailed information, alfresco 3 and 4.

marcosvasousa
Champ in-the-making
Champ in-the-making
[SOLVED]
We tested "> Upgrade to Alfresco 3.4" so we didn't found problems (no code upgrade/change is needed) and after 700 documents in history the time is below 200 ms.
So, we are now Upgranding to Alfresco 3.4.