Lekérdezések és cache a Drupalban, mennyi az annyi?

  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • GeSHi library error: sites/all/modules/geshifilter/geshi is not a directory.
  • The spam filter installed on this site is currently unavailable. Per site policy, we are unable to accept new submissions until that problem is resolved. Please try resubmitting the form in a couple of minutes.
Kategória: 
Leírás

A drupal.hu-n zajlik épp egy nagyon jó kis thread: Adatbázis teljesítmény optimalizálása. A szolgáltató hozzáállása magyar viszonylatban példaértékű, és ez is hozzájárult némileg a motivációhoz, hogy összeszedjem a Drupal 7 cache rendszerével kapcsolatos tapasztalataimat.

Először oszlassunk érdemes kicsit tisztázni a Drupal cache fogalmát. Egyrészt sokannál a cache fogalma kimerül abban, hogy az a pár bekapcsolható izébizé a performance oldalon.

Összességében: Drupal cache nem egyenlő a anonim felhasználóknak bekapcsolható oldal gyorstárral!

A D7-ben eleve nincsen olyan, hogy „bekapcsoljuk a cache-t”. Egy nagyon komplex, többrétű cache-rendszer van, ami az egyes elemek kiszolgálását végzi.

Ezek lehetnek dedikált elemek, mint pl a Menü gyorstár, Token registry. Vagy nem dedikált, hanem egy bármilyen modul által végzett egyszeri gyorstárazási művelet.

Még egy picit mélyebben, megpróbálom egyszerűen összefoglalni: Minden dedikált cache-nek van a Drupalon belül egy definíciója. Ez mondja meg, hogy mi történjen akkor, amikor ezt a cache-t írjuk, vagy olvassuk.
Pont ezek a definíciók teszik azt lehetővé, hogy az összes típusú cachet egységesen írhassuk, olvashassuk. Amit a modulok - illetve természetesen maga a Drupal is - a cache_get() és cache_set() függvényekkel tesznek meg.

Mire kell a cache rendszer?

Egy példa: Egy node megjelenésekor a címkék mellé ki akarunk írni egy számot, ami a node szerzőjének a node tartalomtípusába tartozó olyan tartalmak összege, amely az adott címkével el van látva.

Ez egy közepesen/kevésbé bonyolult lekérdezést jelent, amit kétféleképpen lehet megcsinálni, jól, vagy rosszul. Tegyük fel, hogy megvan a lekérdezés, ott vannak a megfelelő számok a megfelelő címkék mellett. De hogy került oda? Na ez a nem mindegy!

A legrosszabb: A címke kiírásához kapcsolódó preprocess függvénybe írt lekérdezés. Ilyenkor mondjuk egy 10 node teaserből álló, átlag 4 címkével rendelkező lista kiírásához 40!! plusz lekérdezés fog kapcsolódni!

Jó: Hmm.. És itt most viharban lettem, mert egzakt szabály erre nincsen, több módszert kellene kipróbálni, hogy kiválasszam a legjobbat az adott környezethez, feladathoz.

De 1 dolog mindegyik megoldásban benne van: Valamilyen módon fel kell építeni egy objektumot, és eltárolni cache_set()-el. A legkézenfekvőbb egy nodehoz kapcsolódó cache elem felvétele, amiből visszakapjuk a nodehoz kapcsolódó címéket és a kért számot. De meg lehet próbálni közvetlenül abba a cache-ba írni, ami a mező értékeit tárolja - szóval lehetőség van bőven.

Cache a cacheban

Ezek a cache-ok sokszor egymásba épülnek, tehát teszem azt egy nem dedikált cache elem bele fog épülni a page cache-ba (tehát a ki-bekapcsolható anomim oldalcacheba), de például a views dedikált cache-a is ugyanúgy be fog gyógyulni a page cache-ba, tehát anomymus nem fog kapni cache_get-et a viewstól. És ezért emlegettem az elején, hogy Drupalban nincs olyan, hogy "bekapcsoljuk a cache"-t. A legtöbb cache funkciót nem is lehet állítani.

Folytassuk az előző példát:

Kell egy nézet a főoldalra, ami 10 node-ot tartalmaz, benne az általunk elkészített számozott címke mezővel. Szépen beállítottunk cache_setet az eredményünkre nodeonként, és tegyük fel, hogy nem sikerült belegyógyítani a node rendereléséhez használt cache-ba. Hogyan alakulnak a lekérdezéseink bejelentkezett felhasználóknál?

Ebben az esetben 10 többletlekérdezésbe (cache_get-tel kérdezzük le az egy nodehoz tartozó címkék számait) került a 10 node megjelenítése.

És most jön a vudu: Bekapcsoljuk a views gyorstárazását. (a views szerkesztésekor az "Egyéb" szekcióban található) Ez a cache_views_data táblába menti el a lekérdezés kész html eredményét, még az a 10 többletlekérdezésünk is eltűnik, és csak akkor lesz rá szükség, ha a views ezen gyorstárát kell újraépíteni. Tehát a miáltalunk beállított cache a nodeokhoz ezáltal semlegesítődik, az eredménye beleépült a views gyorstárazás eredményébe.

Sőt! Azzal, hogy a views idő alapú gyorstárazását bekapcsoltuk, semlegesítettünk egy rakás más lekérdezéssel járó függvényt, például node_load, user_node_load, comment_node_load.

Mi ebből a tanulság? Bejelentkezett felhasználók esetében a leggyorsabban a views, panels gyorstárazással javíthatunk a teljesítményen.

Ha pedig bekapcsoljuk a gyorstárazást anonim felhasználóknak, akkor a views gyorstár is semlegesítődni fog, mert ilyenkor a cache_page táblából kapja meg a felhasználó az egész oldal renderelt htmljét.

Remélem érthető, hogy miért nem beszélhetünk "cache"-ról a Drupalban.

De akkor miért van mégis egy csomó lekérdezés bekapcsolt anonymus gyorstárazásnál?

Nagyon nem akarok belemerülni a drupal bootstrap folyamatába, de azért néhány példát kiragadnék:

  1. Mindenek előtt be kell inculde-olni a modulok php file-jait.
  2. Fel kell építeni a változókat, amelyekből például azt állapitja meg a drupal, hogy ez most front_page-e vagy nem.
  3. Fel kell építenie egy menüelem-objektumot, amely olyanokat tartalmaz, mint például a felhasználó hozzáférhet-e az adott oldalhoz, vagy nem.
  4. A legtöbb esetben álnevekkel dolgozunk. Meg kell állítani, hogy az adott álnév milyen útvonalhoz kapcsolódik, milyen tartalom tartozik hozzá.
  5. Fel kell építenie egy $user objektumot. Mert bizony, az anonim felhasználó is felhasználó, van neki neve, vannak jogosultságai, a hozzá kapcsolódó adatokat sokszor használják modulok.

És ezek még csak a core dolgai! Egy gyors mérés szerint egy frissen telepített, majdnem szűz drupal kb 30 lekérdezést produkál anonim userek page cacge kiszolgálásakor. Egy komplexebb oldal esetében ez simán felszaladhat 100 fölé.

És igen, szolgáltatóként ezt marha nehéz lekezelni. Engem két olyan oldallal dobtak ki magyar szolgáltatók, amik az én külföldi, jóval olcsóbb és ugyanúgy shared hosting szolgáltatómnak (hehe, ez egy affiliate link. :)) meg se kottyant. Drupallal nagyon könnyű kinőni egy shared hostingot, és nagyon kevés esetben van arra keret, hogy tényleg igazán elejétől a végéig teljesítményoptimalizáljuk az oldalt. Ilyenkor mindenképpen kompromisszumos megoldás kell, erre Drupal vonalon talán a Boost modul a legmegfelelőbb, ha zömében anonim oldallekérések vannak.

Hozzászólások

Hey I know this is off topic

Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates. I've been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.|

Why visitors still use to

Why visitors still use to read news papers when in this technological world everything is available on net?|

I'm not sure where you are

I'm not sure where you are getting your info, but great topic. I needs to spend some time learning more or understanding more. Thanks for magnificent information I was looking for this info for my mission.|

I am sure this post has

I am sure this post has touched all the internet users, its really really pleasant paragraph on building up new weblog.|

Normally I don't learn

Normally I don't learn article on blogs, however I wish to say that this write-up very pressured me to try and do so! Your writing style has been surprised me. Thank you, very great post.|

I have to thank you for the

I have to thank you for the efforts you've put in penning this site. I'm hoping to view the same high-grade content by you in the future as well. In fact, your creative writing abilities has inspired me to get my own, personal blog now ;)|

Have you ever considered

Have you ever considered publishing an ebook or guest authoring on other sites? I have a blog based on the same ideas you discuss and would love to have you share some stories/information. I know my viewers would enjoy your work. If you're even remotely interested, feel free to shoot me an e mail.|

Somebody essentially lend a

Somebody essentially lend a hand to make seriously articles I'd state. This is the first time I frequented your website page and to this point? I amazed with the research you made to make this particular post incredible. Magnificent job!|

I will immediately grab your

I will immediately grab your rss as I can't in finding your email subscription hyperlink or e-newsletter service. Do you've any? Kindly allow me recognise so that I may just subscribe. Thanks.|

May I just say what a comfort

May I just say what a comfort to discover someone that genuinely knows what they're discussing on the web. You actually realize how to bring a problem to light and make it important. A lot more people ought to read this and understand this side of the story. I was surprised you aren't more popular since you surely have the gift.|

We are a bunch of volunteers

We are a bunch of volunteers and starting a new scheme in our community. Your web site offered us with valuable information to work on. You've performed a formidable process and our entire community will be grateful to you.|

Amazing things here. I am

Amazing things here. I am very glad to peer your post. Thanks so much and I am having a look ahead to contact you. Will you please drop me a e-mail?|

You should be a part of a

You should be a part of a contest for one of the most useful blogs on the net. I am going to highly recommend this site!|

I'll immediately snatch your

I'll immediately snatch your rss as I can't find your email subscription link or newsletter service. Do you have any? Please allow me recognise so that I may just subscribe. Thanks.|

Amazing! Its in fact

Amazing! Its in fact remarkable article, I have got much clear idea regarding from this article.|

I every time used to read

I every time used to read article in news papers but now as I am a user of net thus from now I am using net for articles or reviews, thanks to web.|

Asking questions are actually

Asking questions are actually pleasant thing if you are not understanding something completely, except this piece of writing offers good understanding even.|

WOW just what I was looking

WOW just what I was looking for. Came here by searching for %keyword%|

This specific disease may

This specific disease may encompass runny tip and additionally a sore throat.

Hi there mates, how is the

Hi there mates, how is the whole thing, and what you would like to say concerning this piece of writing, in my view its genuinely awesome in favor of me.|

Many people snapshot some

Many people snapshot some sort of Sigmund Freudlike healthcare professional with a persistent resting for the sofa speaking of their very own thoughts if they picture therapy.

The other day, while I was at

The other day, while I was at work, my sister stole my apple ipad and tested to see if it can survive a 40 foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views. I know this is entirely off topic but I had to share it with someone!|

It is usually quickly without

It is usually quickly without getting intense.

Awesome issues here. I'm very

Awesome issues here. I'm very glad to peer your article. Thanks so much and I'm taking a look ahead to touch you. Will you kindly drop me a mail?|

This design is spectacular!

This design is spectacular! You definitely know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it. Too cool!|

Down the road, you may have

Down the road, you may have to reunite using the individuals who penned on hand and skim relating to your weeks together...

Excellent blog here! Also

Excellent blog here! Also your web site loads up very fast! What web host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol|

Very good article! We will be

Very good article! We will be linking to this great post on our site. Keep up the good writing.|

They've got a long background

They've got a long background for the this problem, along with the Fda standards accepting methylphenidate (Ritalin), the amphetamine, found in 1955.

Wonderful beat ! I would like

Wonderful beat ! I would like to apprentice while you amend your web site, how could i subscribe for a blog site? The account helped me a acceptable deal. I have been a little bit acquainted of this your broadcast offered brilliant clear idea|

Thank you, I have recently

Thank you, I have recently been looking for info about this topic for a long time and yours is the greatest I've found out till now. But, what concerning the conclusion? Are you sure concerning the supply?|

Appreciating the dedication

Appreciating the dedication you put into your blog and detailed information you provide.
It's great to come across a blog every once in a while that isn't the same unwanted rehashed information. Fantastic read!
I've bookmarked your site and I'm including your RSS feeds to my Google
account.

Ahaa, its pleasant

Ahaa, its pleasant conversation concerning this article at this place at this web site, I have read all that, so now me also commenting at this place.|

Hey! I could have sworn I've

Hey! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Nonetheless, I'm definitely glad I found it and I'll be bookmarking and checking back frequently!|

Superb site you have here but

Superb site you have here but I was curious about if you knew of any message boards that cover the same topics discussed here?
I'd really like to be a part of group where I can get
feed-back from other experienced people that share
the same interest. If you have any recommendations,
please let me know. Kudos!

I will immediately clutch

I will immediately clutch your rss as I can't in finding your email subscription hyperlink or newsletter service. Do you have any? Please allow me recognize in order that I may just subscribe. Thanks.|

hi!,I like your writing so so

hi!,I like your writing so so much! share we keep in touch more approximately your article on AOL?

I require a specialist on this space to solve my problem.
May be that's you! Taking a look forward to see you.

Hi there, after reading this

Hi there, after reading this awesome piece of writing i am as well happy to share my know-how here with friends.|

Hello! I could have sworn

Hello! I could have sworn I've been to this blog before but after checking
through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be book-marking and checking back frequently!

Hi! Quick question that's

Hi! Quick question that's totally off topic. Do you know how to make your site mobile friendly?
My weblog looks weird when viewing from my apple iphone.
I'm trying to find a template or plugin that might be able to correct this issue.
If you have any suggestions, please share.
Many thanks!

Simply desire to say your

Simply desire to say your article is as amazing. The clearness in your publish is simply excellent and i can assume you are knowledgeable on this subject. Well with your permission allow me to grab your RSS feed to stay updated with imminent post. Thanks 1,000,000 and please carry on the enjoyable work.|

I'm not sure where you are

I'm not sure where you are getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for wonderful info I was looking for this information for my mission.|

Asking questions are actually

Asking questions are actually pleasant thing if you are not understanding something totally, however
this post presents good understanding even.

Hi there friends, pleasant

Hi there friends, pleasant paragraph and good urging commented at this place, I am in fact enjoying by these.|

Hey very interesting blog!|

Hey very interesting blog!|

Hey I know this is off topic

Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
I've been looking for a plug-in like this for quite some time and was hoping
maybe you would have some experience with something like this.
Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to your new updates.

Sweet blog! I found it while

Sweet blog! I found it while surfing around on Yahoo News. Do you have any tips on how to get listed in Yahoo News? I've been trying for a while but I never seem to get there! Appreciate it|

My relatives every time say

My relatives every time say that I am wasting my time here at net, except I know I am getting know-how daily by reading thes pleasant articles or reviews.|

Actually no matter if someone

Actually no matter if someone doesn't know then its up to other viewers
that they will assist, so here it takes place.

It's in fact very complicated

It's in fact very complicated in this active life to listen news on Television, therefore I just use internet for that purpose, and take the most recent news.|

Hozzászólás

A mező tartalma nem nyilvános.
  • Internal paths in double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or relative path.
  • Engedélyezett HTML elemek: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <del> <img>
  • A webcímek és email címek automatikusan linkekké alakulnak.
  • A sorokat és bekezdéseket a rendszer automatikusan felismeri.
  • Engedélyezett HTML elemek: <a> <blockquote> <br> <cite> <code> <dd> <del> <div> <dl> <dt> <em> <li> <ol> <p> <span> <strong> <ul>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <sql>. The supported tag styles are: <foo>, [foo].
  • Minden email cím át lesz alakítva ember által olvasható módon, vagy (ha a JavaScript engedélyezett) ki lesz cserélve kattintható, de biztonságos hivatkozásra.