Support » Plugin: WooCommerce Accommodation Bookings » Really slow product page loading

  • Hi,

    I made a fresh installation with following plugins:
    Woocommerce
    Woocommerce Bookings
    Woocommerce Accommodation Bookings
    using the twentysixteen theme.

    Then I made 1 accommodation booking product and made about 10 bookings for that accommodation. I made bookings from November to January using different bookings range: 2 nights, 7 nights, 3 nights. etc.

    Now when I open the accommodation booking product page on my browser the page load is about 12 seconds and expanding really quickly when adding more bookings for that product. So it is really really slow.

    I managed to debug the problem to a function named “get_blocks_in_range_for_hour_or_minutes” or perhaps in that function the problem is “get_bookable_minute_blocks_for_date”.

    Is there any way to speed up this? If I understood the functionality it checks bookable blocks minute by minute. Why? Hourly check should be just fine or perhaps it should just check whether the checkout time is less than the checkin time -> day is partly booked.

    • This topic was modified 7 years, 3 months ago by JuTu83.
Viewing 15 replies - 1 through 15 (of 18 total)
  • i am experiencing a similar problem with woo booking – without using the accommodations. it worked fine before i updated. any news on that?

    I have the same problem, Booking plus Accommodation extension. When booking a site (product) for a long time, page load times jump from 1 or 2, to 40 to 60 seconds 🙁

    Hey @nickkellett.

    Go to bookings.

    Make sure your cart is not loaded with transients.
    Download wp-optimize to makes sure transients are cleard on a regular basis

    So again

    Bookings>> allbookings >> cart

    Hope this helped

    Thanks @ozomri, I just did what you suggested (installed plugin and optimized) but it didn’t help. The loading time is definitely related to the booking durations, since when I remove a long duration booking the page load time plummets again. I’m got caching enabled but want the availability calendar to reflect accurate data so am reluctant to cache product pages.

    hey nick,

    did you try to manually delete the transients from your cart section as i suggested?

    Hi Ozomri, I did delete the cart transients thanks (there were only a few). The database is pretty empty, and in test mode so not a lot of traffic yet, which is why we are alarmed at the performance.

    did this solve your loading issue?

    No, still an issue for us. I’ve got a dedicated server with fair amount of RAM, have WP Super Cache configured, have tweaked MySQL and everything else is flying, however when I add a long booking to a site it immediately bogs down on page load. I’m not seeing slow queries either but it seems to be taking a long time to complete its work whenever a product with the booking is loaded. Since we do daily availability I found @jutu83’s observation very interesting as a possible culprit. I’m going to try to raise a support ticket with Woocommerce I think. If I learn of a solution I will post back here.

    Hi All, was there ever a solution found for this? We have the exact same problem. We have 90 rooms and with 455 bookings in the system, the product load page becomes unbearably slow often to the point of time out.

    Hey cbcjock.

    For me this was solved by going to woocommerce>o2rders>cart and than cleaning out all the transients. Which are basically unfinished cart action stored by woocommerce.

    You can get a plugin to handle this for you in the future.

    My problem was an error which generated replicas of one order. 2000 of them.

    Anyways that was my solution. Hope it helps.

    O.

    Thanks ozomri, I saw your post above and tried it. Its not causing the problem we are observing.

    We ran the shop locally with webgrind to trace the stack and the bottle neck is ‘get_unavailable_mintues()’ in /includes/class-wc-product-booking.php If you look at that trace, you will see the array_push can be called, in some cases, millions of times. The code isn’t terribly clear but the hypothesis that its checking each minute for a booking definetely seems correct.

    If you then look at class-wc-product-accommodation-booking.php and the return of get_duration_unit(), its ‘night’ This is passed back to class-wc-product-booking.php but the unit only has one use in the entire code, so I believe the system defaults back to ‘minute’ and runs accordingly.

    Long story short, if you change the get_duration_unit() to ‘hour’, the system is about 60% faster. If you change it to ‘day’, the system is over 90% faster (But this is not usable in production systems as you loose the ability to checkin/out on the same day.

    We left get_duration_unit() as ‘night’ and made some changes in the class-wc-product-booking.php to force the system to assume its working with ‘hour’ e.g. Check units are hours and advance all timescales by hours, not minutes. I don’t believe any performance can be gained here as you need the granularity of ‘hour’ but there may be some intelligent shortcuts that could be taken e.g. If the checkin / checkout days are known along with the times, you don’t need to check the whole day.

    • This reply was modified 7 years, 1 month ago by cbcjock.

    I found out from WooCommerce support that the slowness is due to extra availability checks due to the combination of how Accommodation and Bookings plugins interact. So I think cbcjock is correct as to the precise cause.

    A code fix will have to be applied to the Accommodation product, not the Booking plugin. WooCommerce support said they will make a note about that with the Accommodation developers.

    Plugin Support con

    (@conschneider)

    Engineer

    Howdy folks,

    We will be looking into the possible fix by cbcjock. He has an active ticket with us and if possible will open a pull request at: https://github.com/woocommerce/woocommerce-accommodation-bookings

    If anybody else would like to share their solution or input, we are always happy about contributions to WooCommerce Accommodation Bookings. Since WooCommerce 2.7 is on our doorstep, it will be a bit before our developers are able to answer, but we appreciate any input very much.

    Thank you everyone for bringing this to our attention in such a detailed, helpful and professional manner.

    Kind regards,

    Thanks Con, that is good news. And on the topic of professionalism, I will say publicly what I told the WooCommerce support team who worked on my ticket, that I was impressed and pleased by how they handled it.

    cbcjock

    (@cbcjock)

    Hi Folks, thank you for the reply. I won’t be committing any code just yet as I feel there is a better solution for this. From running more tests and looking at the HTML code, the calendar when loaded appears to be requesting all bookings for a given product. So in our case, there might be 100 bookings for a hotel room for a year. This is an awful lot of data to crunch for a user who may be only looking to check in this month for a week.

    I feel a better solution would be to gradually load the calendar, perhaps 3 months at a time as a User clicks through it e.g. A user loads the product page and the first three months are loaded. When I click forward, the next 3 are requested by AJAX. Its far more manageable for the system and should drop the page load time considerably. We can spend all the time we wish improving the back end code but there is no point asking that code to crunch dates that are months in the future that may not be of interest to the average user e.g. Someone booking a room is probably only looking 3 to 6 months in the future, and would probably be ok with a mild blip as they request the next 3 months.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Really slow product page loading’ is closed to new replies.