def with_last_degree(template_layers_config, degree):
    """
    Change the degree of the last -- or actually penultimate -- layer in a
    layered micro-service application, while keeping the average service time
    for a user request constant.
    """
    assert len(template_layers_config) >= 2
    layers_config = [
        layer_config for
        layer_config in template_layers_config]
    layers_config[-1] = \
        layers_config[-1]._replace(average_work=layers_config[-1].average_work/degree)
    layers_config[-2] = \
        layers_config[-2]._replace(degree=degree)
    return layers_config