Some Sitecore Publishing Findings

Well, I do not want to waste your time in explaining how Sitecore publishing works, there are many blogs explaining What is publishing, publishing modes, ways to publish content, versions, target databases, etc. So, I would like to share some hidden secrets about Sitecore Publishing Mechanism, which I learn while exploring it.


Below are the questions mostly Sitecore developers always eager to know:

Why my publish fails or when publish:fail event is called?

While publishing any runtime error occurs like SQL Connectivity loss/Timeout, any SQL Exception, etc. the publish fails. The items already published, cannot be rollback and the items pending to publish needs to be published again. Means, Sitecore publishing does not maintain Transactions.

Check the publishing code from Sitecore.Publishing.Publisher.Publish. The code also contains comments which can explain how publishing works.
public virtual void Publish()
{
    object obj3;
    Monitor.Enter(obj3 = this.GetPublishLock()); // Locks the publishing. That's why publishing is a sequential process.
    try
    {
        using (new SecurityDisabler())
        {
            this.AssertState();
            this.NotifyBegin(); // Raises publish:begin event
            this.PerformPublish(); // Sends the current publish job to start publish
            this.NotifyEnd(); // Raises publish:end event
            this.UpdateLastPublish(); // Updates last publish date in source database
        }
    }
    catch (Exception exception)
    {
        // This function raises publish:fail event.
        this.NotifyFailure(exception);
        throw;
    }
    finally
    {
        Monitor.Exit(obj3);
    }
}

Why my publish expires or when publish:expire event is called?

You might get below configuration setting in web.config file.
     <setting name="Publishing.TimeBeforeStatusExpires" value="02:00:00"/>
If your publishing is taking more than time specified in the setting, the publishing job expires. Here, if your publishing job is taking more than 2 hours, it will get expired. Increasing its value to 5 or 10 hours can solve your problem of expiration if you have to publish thousands of items or heavy media items in one go.

Why my items not getting published?

There can be many reasons behind it:
  • The user publishing the item has not having its rights. Giving rights to the user can do publish.
  • When default/anonymous user's access rights are removed for the item or its parent. Giving rights to the user can do publish.
  • If still you cant find out issue, enable event timing level to high. Now, check logs on publish instance while doing publishing, this will log all events in details and help to identify the cause of problem in publish.
       <events timingLevel="high">
    
  • If you have set a publish instance, check Publish Instance is running or not. It should be up & running.
  • If it is not above case, and still publish not happening, then you need to enable eventqueue on CM as well as PI.
  • If first publish is going on after restart, it can be slow too. It needs to generate more cache and that's why it taking more time. Once cache generated, it will start publishing normally.

What are the reasons for slower publishing?


  • Publishing is a slower process by default as per its process. It requires a lot of processing time, so it consumes lots of CPU resources on Publish Instance. It needs constant updates on web database, so while publishing many insert, update or delete queries are executed. Many caches are cleared.
  • You are publishing many as well as heavy items (items with more size like media files)
  • Have you recently updates Access Viewer to give rights to any Role?
  • Have you checked your target database server is performing well? Checked its IOPS(Input/Output Operations Per Second)?
  • Many publishing or other jobs are in queue. Check below setting in your web.config on your PI.
    <setting name="MaxWorkerThreads" value="20" />
    
    This config determines how many worker threads can be running simultaneously. If your publishing or any other jobs have occupied these (in the example 20) threads, next queued job/publishing has to wait till it gets a free thread. Also, in this situation, your publishing might get stuck.

    You can increase its value as per need. Also remember, greater value can allow more jobs to execute, so may slow down the whole instance.

    You can use Publish Queue Viewer to know how many jobs are running on your instance on:
    - Sitecore Publish Queue Viewer - 1
    - Sitecore Publish Queue Viewer - 2

What can be the optimized publishing approach?

To get best performance with publishing, you might need to take care below things:
  • Proper Cache Tuning on PI as per need
  • Prevent frequent and long publishes
  • Allow Publish Basket facility, means adding media and other items' references
  • Allow scheduling publishing
I'll be posting regarding this very soon!!

How can I setup and use Sitecore Publish Instance?

Refer my earlier post regarding Publishing Scalability or Setting Publish Instance. This post describes how we can set separate Publish Instance and how it works.

Can I use multiple publish instance to support parallel publish?

Many have asked me the question, is it really possible to create Multiple Instances which can do publish parallel? The answer is YES. Although, Sitecore does not recommended this approach as per its architecture. But, Sitecore architecture is so scalable, we can still achieve it.

Refer my earlier post regarding Multiple Publish Instance or Parallel Publishing

Must read posts for Sitecore Publish

- Intelligent Publish in Sitecore - The most optimized approach
- Setup Publish Instance
- Sitecore Parallel Publishing using Multiple Publish Instances

Comments

  1. Hi,
    I am publishing an item to dev server in sitecore, but it is not reflecting immidiatly. It is taking lot of time to relflect in web browser more than 15 hrs. Even i have verified sitecore cache but its cleared.Someone please suggest me in how to triage this issue and help me out to get rid of this issue.

    Thanks,
    Giridhar.

    ReplyDelete
    Replies
    1. Hi Giridhar,

      Can you please tell me how much time it took to finish publishing? If it took just few seconds and took 15 hours to reflect on CD, plz check below things:

      1. Logs of CD server and check publish:end:remote fired or not

      2. If fired, then check whether the HTML cache was cleared or not for this site.

      Do not hesitate to contact me by email : contact@patelyogesh.in for further discussion.

      Delete
    2. This is also possible when invalid configurations are done.

      Delete

Post a Comment