Try this please, Cache configuration

Hi all,

if you don’t use any other cache than the default settings, would you mind trying the following configuration for me and see if it gives you any speed boosts (ideally report with the system you used it on - Win, OSX, Linux, VM, HDD, SDD etc.).

If you are willing try production and development context and make sure you clear caches after setting this.

EDITED:

You can put this in Configuration/Caches.yaml for example:

Neos_Fusion_Content:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    defaultLifetime: 0
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Neos_Fusion_Content.sqlite'

Flow_Mvc_Routing_Route:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Flow_Mvc_Routing_Route.sqlite'
Flow_Mvc_Routing_Resolve:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    defaultLifetime: 0
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Flow_Mvc_Routing_Resolve.sqlite'

Flow_Persistence_Doctrine:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Flow_Persistence_Doctrine.sqlite'

Flow_Security_Authorization_Privilege_Method:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    defaultLifetime: 0
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Flow_Security_Authorization_Privilege_Method.sqlite'

Flow_Cache_ResourceFiles:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    defaultLifetime: 0
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Flow_Cache_ResourceFiles.sqlite'

Neos_Media_ImageSize:
  backend: Neos\Cache\Backend\PdoBackend
  backendOptions:
    defaultLifetime: 0
    dataSourceName: 'sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/Neos_Media_ImageSize.sqlite'

Updated to current namings as of 2023 and added the defaultLifetime of 0, probably some more caches could be added today.

1 Like

I have a slightly better performance (12%) on a Mac with SSD and PHP 7

# BEFORE

ab -c 1 -n 10 http://127.0.0.1:8081/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).....done


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8081

Document Path:          /
Document Length:        65535 bytes

Concurrency Level:      1
Time taken for tests:   5.128 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      657180 bytes
HTML transferred:       655350 bytes
Requests per second:    1.95 [#/sec] (mean)
Time per request:       512.778 [ms] (mean)
Time per request:       512.778 [ms] (mean, across all concurrent requests)
Transfer rate:          125.16 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.5      0       2
Processing:   449  512 110.1    475     787
Waiting:      432  492 104.4    459     757
Total:        449  513 110.5    475     788

Percentage of the requests served within a certain time (ms)
  50%    475
  66%    480
  75%    490
  80%    627
  90%    788
  95%    788
  98%    788
  99%    788
 100%    788 (longest request)

# AFTER

 ab -c 1 -n 10 http://127.0.0.1:8081/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient).....done


Server Software:        
Server Hostname:        127.0.0.1
Server Port:            8081

Document Path:          /
Document Length:        65535 bytes

Concurrency Level:      1
Time taken for tests:   4.588 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      657180 bytes
HTML transferred:       655350 bytes
Requests per second:    2.18 [#/sec] (mean)
Time per request:       458.795 [ms] (mean)
Time per request:       458.795 [ms] (mean, across all concurrent requests)
Transfer rate:          139.88 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       1
Processing:   443  458  11.5    461     479
Waiting:      427  442  10.7    444     462
Total:        443  459  11.6    461     480

Percentage of the requests served within a certain time (ms)
  50%    461
  66%    465
  75%    467
  80%    468
  90%    480
  95%    480
  98%    480
  99%    480
 100%    480 (longest request)

Almost no performance boosts on Ubuntu VM (on SSD) with docker and PHP 7.

# Before 


ab -c 1 -n 10 http://neos.local/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking neos.local (be patient).....done


Server Software:        nginx/1.9.15
Server Hostname:        neos.local
Server Port:            80

Document Path:          /
Document Length:        202602 bytes

Concurrency Level:      1
Time taken for tests:   18.913 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      2028230 bytes
HTML transferred:       2026020 bytes
Requests per second:    0.53 [#/sec] (mean)
Time per request:       1891.320 [ms] (mean)
Time per request:       1891.320 [ms] (mean, across all concurrent requests)
Transfer rate:          104.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:  1797 1891  56.4   1890    1982
Waiting:     1775 1866  55.1   1865    1956
Total:       1798 1891  56.4   1890    1983

Percentage of the requests served within a certain time (ms)
  50%   1890
  66%   1895
  75%   1934
  80%   1957
  90%   1983
  95%   1983
  98%   1983
  99%   1983
 100%   1983 (longest request)

# After

~ ab -c 1 -n 10 http://neos.local/
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking neos.local (be patient).....done


Server Software:        nginx/1.9.15
Server Hostname:        neos.local
Server Port:            80

Document Path:          /
Document Length:        202602 bytes

Concurrency Level:      1
Time taken for tests:   17.760 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      2028230 bytes
HTML transferred:       2026020 bytes
Requests per second:    0.56 [#/sec] (mean)
Time per request:       1776.048 [ms] (mean)
Time per request:       1776.048 [ms] (mean, across all concurrent requests)
Transfer rate:          111.52 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:  1750 1776  19.1   1773    1811
Waiting:     1723 1749  18.4   1746    1783
Total:       1750 1776  19.1   1773    1812

Percentage of the requests served within a certain time (ms)
  50%   1773
  66%   1776
  75%   1785
  80%   1803
  90%   1812
  95%   1812
  98%   1812
  99%   1812
 100%   1812 (longest request)

Sorry, would like to help/share experience, but get the error:
#1370964557: The session meta data cache must provide a backend implementing the IterableBackendInterface, but the given backend "TYPO3\Flow\Cache\Backend\PdoBackend" does not implement it.

after I copy & paste your Code from [quote=“christianm, post:1, topic:1313”]
TYPO3_TypoScript_Content:
[/quote]
to [quote=“christianm, post:1, topic:1313”]
dataSourceName: ‘sqlite:%FLOW_PATH_TEMPORARY%Cache/Data/TYPO3_Media_ImageSize.sqlite’
[/quote]
(42 Lines)
into: root/neos-base-distribution/Configuration/Caches.yaml and flush the cash.

Same in other installation without neos-base-distribution: root/Configuration/Caches.yaml. After deleting the content in Caches.yaml all is like before :thinking:.
Maybe I misunderstood something in your advice!?

@mad: The PdoBackend implements the IterableBackendInterface only in master-Branch.
(see this commit: 10276545b52e621e8549c50e9aaff382ba710071)

FYI: I edited out the session stuff, should work in stable as well now.

Is this for 2.2 only, or can i also try this on 2.1?

I think the edited variant should work in 2.1 as well.

Hi,
first time ab-using, hope these values helps. Suspect much longer time :weary: and three times not really pleasant results.

System OS X 10.11.6 on SSD, MAMP PRO

  • Medium complex website
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking test.neos (be patient).....done


Server Software:        Apache
Server Hostname:        test.neos
Server Port:            80

Document Path:          /
Document Length:        45864 bytes

Concurrency Level:      1
Time taken for tests:   55.915 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      460590 bytes
HTML transferred:       458640 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5591.451 [ms] (mean)
Time per request:       5591.451 [ms] (mean, across all concurrent requests)
Transfer rate:          8.04 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:  5574 5591  28.8   5583    5671
Waiting:      556  571  27.9    562     648
Total:       5575 5591  28.7   5583    5671

Percentage of the requests served within a certain time (ms)
  50%   5583
  66%   5584
  75%   5587
  80%   5596
  90%   5671
  95%   5671
  98%   5671
  99%   5671
 100%   5671 (longest request)

# after flush cache and reload one-time in browser (otherwise much longer loading-time 90%-100%)

Benchmarking test.neos (be patient).....done


Server Software:        Apache
Server Hostname:        test.neos
Server Port:            80

Document Path:          /
Document Length:        45864 bytes

Concurrency Level:      1
Time taken for tests:   55.933 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      460590 bytes
HTML transferred:       458640 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5593.260 [ms] (mean)
Time per request:       5593.260 [ms] (mean, across all concurrent requests)
Transfer rate:          8.04 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  5565 5593  19.1   5594    5626
Waiting:      546  573  17.5    573     604
Total:       5565 5593  19.1   5595    5627

Percentage of the requests served within a certain time (ms)
  50%   5595
  66%   5595
  75%   5601
  80%   5619
  90%   5627
  95%   5627
  98%   5627
  99%   5627
 100%   5627 (longest request)

result: median: 5583(old) to 5595(new) => equal.


  • More complex site: 1839 nodes, less images
Benchmarking test.neos (be patient).....done


Server Software:        Apache
Server Hostname:        test.neos
Server Port:            80

Document Path:          /test-with-many-elements.html/
Document Length:        241912 bytes

Concurrency Level:      1
Time taken for tests:   55.794 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      2421080 bytes
HTML transferred:       2419120 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5579.373 [ms] (mean)
Time per request:       5579.373 [ms] (mean, across all concurrent requests)
Transfer rate:          42.38 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  5559 5579  15.6   5580    5604
Waiting:      538  559  15.2    562     580
Total:       5559 5579  15.6   5580    5605

Percentage of the requests served within a certain time (ms)
  50%   5580
  66%   5584
  75%   5592
  80%   5597
  90%   5605
  95%   5605
  98%   5605
  99%   5605
 100%   5605 (longest request)

# after flush cache and reload one-time in browser (otherwise much longer loading-time 90%-100%)

Benchmarking test.neos (be patient).....done


Server Software:        Apache
Server Hostname:        test.neos
Server Port:            80

Document Path:          /test-with-many-elements.html/
Document Length:        241912 bytes

Concurrency Level:      1
Time taken for tests:   57.237 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      2421080 bytes
HTML transferred:       2419120 bytes
Requests per second:    0.17 [#/sec] (mean)
Time per request:       5723.720 [ms] (mean)
Time per request:       5723.720 [ms] (mean, across all concurrent requests)
Transfer rate:          41.31 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:  5567 5723 444.5   5586    6988
Waiting:      548  702 440.5    567    1956
Total:       5567 5724 444.5   5586    6988

Percentage of the requests served within a certain time (ms)
  50%   5586
  66%   5589
  75%   5592
  80%   5610
  90%   6988
  95%   6988
  98%   6988
  99%   6988
 100%   6988 (longest request)

result: median: 5580(old) to 5586(new) => equal.


  • default demo-website, no change
Benchmarking demo.neos (be patient).....done


Server Software:        Apache
Server Hostname:        demo.neos
Server Port:            80

Document Path:          /
Document Length:        8761 bytes

Concurrency Level:      1
Time taken for tests:   56.050 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      89550 bytes
HTML transferred:       87610 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5605.007 [ms] (mean)
Time per request:       5605.007 [ms] (mean, across all concurrent requests)
Transfer rate:          1.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:  5491 5605 314.2   5507    6499
Waiting:      474  579 293.7    487    1414
Total:       5492 5605 314.1   5508    6499

Percentage of the requests served within a certain time (ms)
  50%   5508
  66%   5509
  75%   5509
  80%   5516
  90%   6499
  95%   6499
  98%   6499
  99%   6499
 100%   6499 (longest request)

# after flush cache and reload one-time in browser (otherwise much longer loading-time 90%-100%)

Benchmarking demo.neos (be patient).....done


Server Software:        Apache
Server Hostname:        demo.neos
Server Port:            80

Document Path:          /
Document Length:        8761 bytes

Concurrency Level:      1
Time taken for tests:   55.148 seconds
Complete requests:      10
Failed requests:        0
Total transferred:      89550 bytes
HTML transferred:       87610 bytes
Requests per second:    0.18 [#/sec] (mean)
Time per request:       5514.777 [ms] (mean)
Time per request:       5514.777 [ms] (mean, across all concurrent requests)
Transfer rate:          1.59 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:  5497 5515  10.9   5515    5536
Waiting:      476  494  11.1    497     515
Total:       5498 5515  10.9   5515    5536

Percentage of the requests served within a certain time (ms)
  50%   5515
  66%   5520
  75%   5521
  80%   5522
  90%   5536
  95%   5536
  98%   5536
  99%   5536
 100%   5536 (longest request)

result: median: 5508(old) to 5515(new) => equal.


sorry for three times unpleasant results. Maybe I did something wrong.
For analysis I always use the same procedure:

  • paste and save (for old), or delete and save (for new) the content in root/Configuration/Caches.yaml
  • flush the cache
  • load the website 1 time in browser
  • than use «ab» in terminal

Thanks for the numbers. I mean I am trying to figure out how it behaves so any numbers are good. i would love to see production context and a bit more concurrency though…

Hi,

so I adapted the ```Caches.yaml file on our production system today.

The frontend loading times stayed practically the same (TTFB ~150ms on average, okay for a shared host on PHP 7 without any special caching mechanism I’d say. Neos is on 2.1.9).

But I expect a huge performance improvement for the backend. This site used to create 6000+ Cache files in less than a week for content cache alone. So after a couple of weeks the backend was so slow, that the editors could not really work on the content anymore, unless i cleared the cache.

The backend loading times just before and after the change looked like this:

File Cache (cache cleared recently)

SQLite Cache:

I wish I had a screenshot from the times the cache was “full” and the backend got really slow.

As i said before, I expect the largest difference after the site ran for a couple of days and my editors do not complain about waiting 5 seconds for changing the document :slight_smile:

Dunno if my numbers are of any help, but when this fixes my file cache issue without having to implement an ACPu cache (which I never got around to), I would gladly use this on all of our sites!

Will report back in a couple of days and report about the editor experience.

2 Likes

It’s been 14 days and the backend is still fast as ever (compared the numbers above, no noticeable performance loss).

With the standard file cache configuration the loading time would be at 5-10+ seconds by now, but the sqlite cache is still holding up very well.

TYPO3_TypoScript_Content.sqlite is at 153,2 MB. I guess most of the nodes are cached by now.

Great to hear!

Better late than never:

VERY IMPORTANT INFORMATION

Be aware that the PdoBackend Cache in Flow has a default lifetime of 3600 seconds. See:
https://flowframework.readthedocs.io/en/stable/TheDefinitiveGuide/PartIII/Caching.html#common-options

So you’ll need to add this option to each entry above to avoid cache expiration every hour:

    defaultLifetime: 0

Maybe @christianm can add this to his code sample and extend the backendOptions

Be aware that this has nothing to do with your maximumLifetime setting in your Fusion cache configuration!

1 Like

Hey Gerhard,
I would use the setting defaultLifetime: 0 for Neos_Fusion_Content. But first i would have a question: Has this setting negative effects in the productive system?

Thank you!

Welcome Demet :slight_smile:
I would say it only has positive effects for your system in production since this avoids automatic cache invalidation after 60 minutes. As long as your Neos Fusion Cache configs are set correctly it’s never necessary to invalidate caches after a fixed period of time, but only if some cache entry tags change. The default (file) cache backend does just the same, with the caveat that it becomes very slow when the number of files grows.

See https://neos.readthedocs.io/en/4.0/CreatingASite/ContentCache.html#cache-entry-tags for more information on this topic.

1 Like

Should be Neos\Cache\Backend\PdoBackend instead.

Thx @christianm, I tested the sqlite backend for any filesystem cache that has more than a few hundred entries in a large 8.3 project and achieved a verifiable speedup locally on my Mac between 3-11%. This could probably be more in the Kubenetes based production environment. Will update my post when I can test it there.
The most relevant caches were already in Redis, so I didn’t really expect this much.

Update: They asked me to test whether those caches would be better in Redis instead of sqlite and the result was, that the performance was actually worse than the filesystem backed one.

Update: My changes to adjust some backend to sqlite besides others already residing in Redis improved the production system performance by ~15% :slightly_smiling_face:

2 Likes

@christianm any reason why we don’t change the recommended (or even distribution default) cache configs to use MultiBackends/TaggableMultiBackends with the default being sqlite and the fallback the previously used FileBackends?

1 Like

I think that could be feasible, not sure about the performance impact of multi backend, I would usually only use it when I really need multiple backends and not as a default. Would potentially also break existing config (think lifetime or filepath) if we change the default config.

I’d say 9.0 can come with SQLite as default be if the flow setup detects that that won’t work out because of the rare case the phpextension not being there, we can give a hint to use the file backend.