Mailchimp API usage on reg form

tomchuk - September 17, 2009 - 00:17
Project:MailChimp
Version:5.x-2.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

So I'm running a fairly large site, that just underwent a redesign including having the user_register form appearing in a slide-down panel on every page, with mailchimp integration on said form. I just got an email from MailChimp API support asking me nicely to look into my API usage - the email featured such words as "now", "asap" and "620k requests in 2 days."

So it looks like the user_register integration was making a call to login() and lists() on every pageload (good luck for us and mailchimp that those 620k calls only accounted for the <5% of our traffic that is not cached).

Here's a patch to mailchimp.module that adds a little caching around the _mailchimp_get_available_lists() call in hook_form_alter so that the API call is only made once a day in the context of the registration form. Not sure if it's applicable to most sites, but I promised I'd post it here in case it was.

AttachmentSize
mailchimp.module.diff838 bytes

#1

LouBabe - September 17, 2009 - 18:08
Status:needs review» won't fix

Thanks tomchuk, that's a good approach. I'm working on a new major release, in the 6.x-2.x branch, which will address this caching issue. I'll review your patch and maybe use the concept. I'm leaning in the direction of storing all the available lists in local variables anyways, which would eliminate the need for additional caching. I'm not planning any new releases for 5.x, but it's great to have this available for users that may want to use it.

 
 

Drupal is a registered trademark of Dries Buytaert.