Leaseweb / LswMemcacheBundle

Symfony bundle for Memcache Doctrine caching and session storage in the Web Debug Toolbar.
MIT License
202 stars 57 forks source link

Symfony reporting 2x memory usage #7

Closed agemmell closed 11 years ago

agemmell commented 11 years ago

Hello! I am just starting out using Memcached with Doctrine (in Symfony) and I've gone straight to using your bundle to help me do that.

I am testing the Memcached caching on an API call which makes just 4 queries but returns a lot of data. This data is parsed and output as JSON. I intend to simply cache those 4 queries.

Straight away I am experiencing something surprising. Symfony's debug bar is now reporting roughly twice the memory usage (~118MB) than when I am not using Memcached (~55MB). My question is simply this: is this normal? I was actually expecting much LESS memory to be reported as being used because the DB wouldn't be hit. Can anyone explain why it virtually doubled?

I presume the DB memory is being saved (I'm not sure how to measure this?) but why has this led to an increase in PHP memory?

My config is a virtual copy and paste of your default except I don't want to cache my sessions:

lsw_memcache:
#    session:
#        client: default
    doctrine:
        metadata_cache:
            client: default
            entity_manager: default          # the name of your entity_manager connection
            document_manager: default        # the name of your document_manager connection
        result_cache:
            client: default
            entity_manager: default
            prefix: "result_"                # you may specify a prefix for the entries
        query_cache:
            client: default
            entity_manager: default
    clients:
        default:
            hosts:
              - { dsn: localhost, port: 11211 }

Thank you for any light you can shed on this.

mevdschee commented 11 years ago

When in debug mode the debugger (that allows you to look at the memcache calls) will store all the requests and responses in RAM. This might be causing the high RAM usage. In production mode you should not be seeing this high RAM usage. Tell me whether that answers your question or not.