def parse_rate(rate):
    """Given the request rate string, return a two tuple of:
    <allowed number of requests>, <period of time in seconds>
    """
    if rate is None:
        return (None, None)

    num, period = rate.split('/')
    num_requests = int(num)
    duration = {
        's': 1,
        'm': 60,
        'h': 3600,
        'd': 86400,
        'j': 86400 * 30,
    }[period[0]]
    return num_requests, duration