====== New Rotation FAQ ====== ===== What is mod_rewrite ===== mod_rewrite is a module for Apache that allows you to make "beautiful" URLs. The same module is available for both nginx and lighttpd. For example, default template URLs look like http://domain/gallery/cool-gallery/index.html, even though no such physical path exists on the server. The rewrite rule converts that URL into something like http://domain/scj/tube/?slug=cool-gallery. The human-friendly URL is there for search engines and users. The .htaccess file created during setup contains these rewrite rules. A simple explanation of how it works: As mentioned above, /gallery/cool-gallery/index.html does not really exist on the server. To open that gallery directly, the real URL would have to be something like /scj/cgi/out.php?url=content&slug=cool-gallery, which is not very clean. So we add a rewrite rule to .htaccess that tells Apache how to transform one URL into another. In this case the rule is: RewriteRule ^gallery/(.*)/index.html$ /scj/cgi/out.php?url=content&slug=$1 This means: if the URL starts with gallery/, then has some value captured by (.*), and ends with /index.html, it matches this rule. Each captured part gets its own number: the first one is $1, the second would be $2, and so on. In this example, $1 becomes cool-gallery. Apache therefore rewrites the URL to /scj/cgi/out.php?url=content&slug=cool-gallery and the gallery is shown. URLs like /gallery/cool-gallery/index.html appear on pages because subtemplates contain markup like this: href="/gallery//index.html So if you want to change the URL format on the site, you need to change both the subtemplate and the rewrite rule so they match each other. ===== Why in Rotation - Groups does it show 10 gallery in my group, but on the site page or Rotation - List thumbs 20 ===== One gallery can belong to more than one group (category). You can see this when editing any thumb: it has one main group and multiple extra groups. Rotation - Groups counts only by the main group, so you can clearly see how many unique galleries there actually are. For example, we have 2 groups A and B. and 2 galleries - one has main group A, the other has main group B. But both have A and B marked in the ext groups field. Rotation - Stats will show that we specifically have 2 galleries, one in group A and one in group B. On the site, in each of the groups you will see 2 galleries. ===== Custom gallery with my local content ===== - Upload anywhere thumb - when importing, specify Image List = listing of URLs of images ===== What is Init cats in Rotation - Special or why I added a category in the admin panel, but it didn’t appear on the site ===== Recalculating categories, namely choosing the best category thumb and counting how many thumbs there are in a category, is a rather difficult task for the server, so it does it once every 15 minutes, stores the result in cache and all other parts of the script use cache. Init cats is a forced launch of this operation. If you have added a new category, it will appear in a maximum of 15 minutes, if you need it faster, click this button. ===== What is cache ===== The script does not generate static HTML pages (see the question about mod_rewrite above), all pages are dynamic. In order not to recreate the page for each user, the script creates it once and saves it in cache for a certain time (CACHE_TIME), the next visitor during the lifetime of the cache will receive this page from the cache, without loading the server. The cache time is set in common.php CACHE_TIME, starting from update 46, the time in common.php can not be specified, but can be specified in the rotation settings. Please note that the time specified in common.php takes precedence; if specified in common.php, the script ignores the rotation settings. In order to view a page without cache, you need to add the skip_cache=true parameter to the URL. For example, http://domain.com/?skip_cache=true Starting with update 46, recreate cookie appeared - Rotation - Special - Recreate visited pages - the script places a secret cookie in your browser for 10 hours (you can remove the cookie at any time there). If you access any page of your site with this cookie, this page will be recreated (the cache for this particular page will be reset). It can be useful when changing the design of one specific page. The difference between skip_cache and recreate cookie is that skip_cache will show the page without cache only to you and that’s it, and recreate cookie will show the page without cache, then it will be put in the cache as you see it and other users will see it from the cache in this form. Once again: the page was created at 00 minutes. Cache time 10 minutes. in 05 you change the design. if you looked at it in 05 with skip_cache, you will see a new design, but a user who came in 06 (before the cache expires) will see the old design. if you open a page with a recreate cookie in 05, then the user who came in 06 will see the new design. ===== Cache Engines (New) ===== The basic principle of the engine is to generate the desired page, put it in the cache for a certain time and display it until the cache is cleared. What engines are currently available: **File** Basically cache is stored in files (scj/cache - file cache). Pros - it works everywhere and at once. The disadvantages are that it is a file cache, it is not as fast, the cache system is not as efficient as we would like, and you have to separately take care of the size of the cache folder. **Memcached** At one time, this was certainly a big step forward in terms of cache. Pros - everyone knows it, admins install it on hosting without any problems, it’s easy to administer, etc. Disadvantages - it is almost impossible to get any understanding of the actual memory occupied; when the server is overloaded, the entire cache is deleted and you need to “warm up the cache” to put the most used data there. When the server is overloaded due to load, this is a serious problem - the server is already loaded, and then all the cache has disappeared. All data is cached equally - it doesn’t matter if it is the most used or used once an hour - they all hang in the same memory and the service does not know how to dump them to disk, for example. With memcache, you cannot clear cache for one site only. All sites share the same cache space, so clearing it affects every site at once. You can of course run multiple memcache instances on different ports, but that usually requires admin help and is inconvenient in practice. How to install: - ask the admin to install Memcached - register memcache in the config $config['memcached_host'] = '127.0.0.1'; $config['memcached_port'] = '11211'; **Therefore, now there are new engines that are recommended for use** In new engines, which are basically called NoSQL solutions, there are many more possibilities than will be described below, but for current cache purposes the basic ones will be described. The easiest solution to switch to is **Couchbase** **CouchBase** is a continuation of MemBase, apparently the closest descendant of memcachedb, which in turn comes from memcached. The main thing is that practically no movements are required from you in order to start using it. You install CouchBase and it works exactly the same as memcache. In order to start using it you need - ask the admin to install CouchBase - add extension couchbase to PHP - register in config.php $config['couchbase_host'] = '127.0.0.1'; $config['couchbase_port'] = '11210'; $config['couchbase_username'] = 'testuser'; $config['couchbase_password'] = 'testuser'; $config['couchbase_bucket_name'] = 'test'; and that's it, you are already using a modern version of memcache. You can use this even with version 48-49. **How is this better than memcached** * There is no concept of "warming up cache". In fact, this is a file cache, but made an order of magnitude more correctly, which loads the disk much less, calculates when and how best to write data in blocks to disk, etc. In this case, the data lies in several files, and not in hundreds of files like a file cache. * Parsed data disappears from the disk/memory on its own; you don’t have to worry about it yourself. * You can, just like with memcache, limit the amount of memory allocated for cache, but cache will not be limited by this amount. Even if there is more data, it will leave the most active ones in memory and download the rest to disk. And loading the required element from disk is faster than generating it again. * You can quickly and easily scale the system from the web admin panel. * You can also create several separate caches. In Couchbase this is like running several memcache instances, but everything is managed from the web admin panel, which is much faster and more convenient. For example, you can create 10 caches, each on its own port, and assign a separate port to each site. In that setup, the long-requested “Delete all cache” button effectively becomes possible, because you can clear the full cache for one site only. * When moving, cache is easy to copy because it is not a lot of small files that are copied, as with a file cache, but one database. **Redis** is a separate NoSQL database project written from scratch. Its meaning for our purposes is almost the same (in reality, couchBase is more of a document oriented storage, and Redis is a purely key-value storage). To work with it, functionality was added in version 50. In order to start using it you need - ask the admin to install Redis - ask him to install the redis module for PHP - register in config.php $config['redis_host'] = '127.0.0.1'; $config['redis_port'] = '6379'; $config['redis_database'] = 0; $config['redis_password'] = ''; if redis is hanging on a socket it will look something like this $config['redis_host'] = '/tmp/redis.sock'; $config['redis_port'] = '0'; and that's all. In this config, in addition to the clear fields, there are several new ones. redis_password - in most cases it is not relevant since now everything is on dedicated servers. redis_database - Redis does not have alphabetic database names, but rather numbers. If you have several sites, you can give each site its own number. But you don’t have to specify it and use one database for all sites. The difference will be that if you want to reset the entire cache and you use one database for all sites, the cache will be deleted for all sites. If each site has its own database, the cache will be chipped in for one. **How is this better than memcached** * All the same advantages apply to couchbase. * Redis is a more cache-specific solution, but CouchBase has a ready-made convenient admin panel (talking about version 2+). ===== Where is cache stored? (memcache) ===== By default, a file cache is used (stored in /scj/cache), but you can also use, for example, Memcache. To do this, you just need to add it to scj/includes/config.php $config['memcached_host'] = 'localhost'; $config['memcached_port'] = '11211'; The address and port may change (check with your admin), but in most cases they will be the same. It makes sense to configure memcache to work via socket - it's faster. In this case, the config will be something like this $config["memcached_host"] = "unix:///tmp/memcache.sock"; $config["memcached_port"] = 0; There are several nuances: - file cache is not as slow as it may seem. In practice, the difference is often smaller than people expect. - with file cache, the cache stays on disk. If the server is overloaded or restarted, the cache does not simply disappear and the script does not have to rebuild everything from scratch. With memcache, the entire cache can be lost, and then the script must regenerate many pages on the fly, which creates extra load again. If you do use memcache, make sure it has enough memory. The exact amount depends on database size and on how heavy your templates are, since the cache stores the generated HTML itself. As soon as memory runs out, pages start being regenerated on the fly. Memcache size also matters because old entries are evicted when space is needed. For example, if the cache can hold 10 one-megabyte entries, adding an eleventh entry pushes the oldest one out. Another issue is fragmentation: memcache stores data in blocks, so real memory usage is higher than the reported payload size. Roughly speaking, if a block is 100 bytes and you save 1 byte, statistics may report 1 byte while 100 bytes are actually occupied. If an entry is evicted, memcache does not report an error back to the script, so the script cannot react to that directly. A rough practical estimate is about 15% fragmentation. ===== Why in my admin panel and on such and such a page of the site the thumbs are in a different order ===== With the same sorting, the order should be the same, taking into account the following nuances: 1. in the admin panel it shows the name as it is in the database according to CTR, for example, on the site page in some places there may be “new thumbs” that are being tested. For example, on the page thumb 123 is in 15th place, and in the admin panel it is in 50th place. This is probably a new thumb that the script is testing. 2. The new thumb may get an unexpectedly high CTR. For example, they showed it 2 times and clicked on it 1 time = CTR 0.5, but 2 impressions are not a reason to judge that the thumb is good. Therefore, by default, “new” thumbs are not shown in first place. You can change this in settings (New Rotation: New thumbs placement : Place new thumb (shows less then New thumbs timelive) on places other then Test positions start if it has good CTR. ). It’s easy to check if you select New Thumbs = dont show new in List Thumbs. ===== Why is there an empty tag cloud on my page ===== A tag cloud is generated from active tags every 30 minutes and stored in cache. Accordingly the options: * no active tags * less than 30 minutes have passed * you nailed cache ===== Thumbs (galleries) are not deleted ===== * previously there was a problem when deleting a large number of thumbs. For example, if one sponsor had 10k thumbs and you deleted that sponsor, the script tried to remove everything immediately and could hit a timeout. The issue was even worse if you needed to remove not just thumbs, but a full custom gallery. * now thumbs are deleted by cron. When you click “delete” in the admin panel, the thumb is not deleted instantly. It is moved to the 'Marked for deletion' status, and every 10 minutes cron checks for such items and removes them * if you need to delete “right now” - run rotation.php with the parameter process_deleted=true * cd /PATH_TO_/scj/bin/; env HTTP_HOST=yourdomain.com php rotation.php process_deleted=true * the only exception: if you delete a thumb in Rotation - List thumbs and less than 30 thumbs are deleted, then the deletion occurs immediately. The deletion speed is hard to predict and depends on the number of galleries involved, current server load, whether a custom gallery is involved, and whether the files are on the current server or on FTP. ===== How much traffic is needed to rotate thumbs ===== It is not necessary to revise everything to the end for good sales, but in general it is very easy to calculate how much traffic you need. A thumb is considered rotated after it has been shown New thumbs timelive times, which is 500 by default. Let’s say there are 200 thumbs on the page, and the default percentage of test positions on the page is 15. That means new thumbs will be shown in 30 of those 200 positions. Every visit to the page means +30 impressions for new thumbs. For example, we have 10,000 thumbs, to rotate them we need 10,000*500 = 5,000,000 impressions. One visit to the page is 30 impressions, but to rotate the base to 10k we need 5M / 30 = 167k page loads. ===== Not every thumb of a gallery is tested ===== Apart from the banal lack of traffic, it usually means that the gallery has, for example, 10 thumbs, but only one has impressions. How this happens: for example, we have 100 galleries of 10 thumbs, 20 thumbs on the page. Let's start rotation. All have a CTR of 0. We displayed the first thumb with gallery ID 1 - 20. They received a CTR greater than 0. We need to refresh the page. test ones for example 5 on the page. We display IDs 1 - 15 as the 15 best (and so far only the first thumb from the gallery has received CTR and impressions). And then 5 test ones - here we can take thumb number 2 with gallery ID 16-20 It turned out that these thumbs scored less than thumb 1 gallery ID 1-15, we take for example the 3rd thumb with gallery ID 16-20. Thus, it turns out that gallery ID 1-15 has impressions only for the first thumb. When their CTR is less than the CTR of others, they will be “squeezed out” from the top. They also have the opportunity to be shown on page 2 of the pagination, but again, provided that your traffic reaches the 2nd page. ===== Parameter out.php &link= ... ===== Initially, out.php has a &link=blabla parameter, the meaning of which is that statistics on blabla can be seen Stats - Links. But rotation uses it to pass rotation parameters (12x123x1234). This looks very simple in practice: for example, the link /gallery/cool-desc/index.html?12x345x567 rewrite (see what it is above) is converted into a URL like out.php?slug=cool-desc&link=12x345x567 and later the script processes statistics on links, converting this into statistics on thumb. Accordingly, if you have a URL like out.php?member=domain.com&link=top, then this option still works the same, but it cannot be used for rotation links. In order to solve this situation, another parameter &link2 was introduced, the meaning of which is that you can do out.php?slug=cool-desc&link=12x345x567&link2=blabla and still view statistics on links and rotate the thumb at the same time. ===== What are thumb categories ===== A category thumb is the default thumb for a category. However, you can configure the script to use a thumb that is not the absolute best one, for example the 2nd or 3rd by CTR. These settings are available in Rotation - CMS - Settings. ===== How to create a master site from a slave ===== - Dump the master database - We look in rot_linked_db for the number of the slave that we are disconnecting (X) - Disconnect the desired slave from the master - Fill the database with the former on the left (dump) from point 1, but only the tables rot_gallery_info, rot_gallery_statsX, rot_gallery_dataX and rot_thumbs - rename rot_gallery_statsX to rot_gallery_stats1, rot_gallery_dataX to rot_gallery_data1 ===== Gallery statuses ===== Pool - Active - Old - actually necessary for Shift settings to work in rotation groups. The point is to fill the site automatically. So you added a lot of galleries to the pool status, set 10 galleries to be added once a day and the site adds them from the pool to active ones, and they appear on the site. This gives the appearance of daily updates. Old - if you want to remove old galleries from the site while keeping the total number the same. On the site, the listing shows only galleries with the active status. preload - galleries are added to Preload (in the admin panel) so that you can choose which of the grabbed thumbs will eventually be on the site. Those that you do not select will be deleted. to_grab - when galleries are added to the database they receive this status before the grabber creates a thumb for them. At the moment thumbs are created, they receive the processing status. to regrab - gallery is waiting for regrab. to delete - gallery is waiting to be deleted. Many galleries are marked for deletion, and it is impossible to delete them instantly, especially grab error - if something went wrong while grabbing thumb, the gallery is either deleted or given the grab error status depending on your settings. Banned - the URL remains in the database and will not be added again. Like grab error, this only makes sense if you are adding a gallery via import sets and there is a possibility that some galleries will be added again and again. For example, you add a set through import, gallery goes to preload. You selected part of the gallery, but decided not to add some. An hour later, this import set is added again, and there is the same gallery again - it will again end up in preload and you will have to sift it out again. To avoid that, you can add it to banned. The downside is that the database in this case grows and there is a gallery that is not used, but takes up space in the database. Inactive (the equivalent of hidden in version 1.X) means the gallery is not shown in listings, but is still available by direct URL. For example, imagine a gallery was indexed but hotlinked its content from somewhere else. Later the source content was deleted and the gallery stopped working. Previously, the checker could delete such galleries, or mark them inactive. The downside was that for CE spiders the old URL would now return 404. In some cases it is better to return a page without content instead of a 404. That is what the “Hidden” status is for: the gallery remains accessible by direct URL, but its thumb is removed from rotation. This status can be assigned by an import set that removes galleries. Gallery Checker has a similar option. The exact effect of this on the CE is unknown. ===== Category statuses ===== Categories have 3 statuses: - active - displayed in