drupal commerce membership expiration
If your "membership" is already implemented as a role, you could use the Commerce License module (the Commerce License Role submodule).  In the UI, licenses can be assigned to have default lengths that will automatically be set upon purchase; if you need to change lengths, you can also configure rules to do so.