How do I synchronize users and their roles between sites?
Hope the question is for Drupal 7 or lesser. If it's for Drupal 8, the solution is close to impossible. And for future Drupal versions, as per the current plan for Drupal 9, multi-site option itself shall not be available, which mean sharing user role using Drupal's default options, is clearly impossible.

In Drupal 7 or lower, in the multi-site setup, it's very easily possible to configure each site to use different databases for their contents, and share the same table (from same database) just for users, roles, sessions, etc. If you don't want to share users, but want to share only roles, even that is possible. For this, the settings.php for site A and site B has to be as below:

settings.php for Site A:

/*
 * Database Settings for 'Site A'
 */
$databases['default']['default'] = array (
    'database' =&gt; 'site_a_db_name',    // Specify Site A's main database name
    'username' =&gt; 'site_a_db_username',
    'password' =&gt; 'site_a_db_password',
    'prefix' =&gt; array(
        'default' =&gt; 'site_a_prefix_',    // Prefix for all tables in Site A's main database (specified above), other than for the tables specified below
        'role' =&gt; 'shared_db_name.shared_prefix_',              // Shared database name and prefix for the 'role' table
        'users' =&gt; 'shared_db_name.shared_prefix_',             // Shared database name and prefix for the 'users' table
        'authmap' =&gt; 'shared_db_name.shared_prefix_',           // Shared database name and prefix for the 'authmap' table
        'sessions' =&gt; 'shared_db_name.shared_prefix_',          // Shared database name and prefix for the 'sessions' table
        'profile_fields' =&gt; 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_fields' table
        'profile_values' =&gt; 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_values' table
    ),
    'host' =&gt; 'localhost',
    'port' =&gt; '3306',
    'driver' =&gt; 'mysql',
    'collation' =&gt; 'utf8mb4_general_ci',
);


settings.php for Site B:

/*
 * Database Settings for 'Site B'
 */
$databases['default']['default'] = array (
    'database' =&gt; 'site_b_db_name',    // Specify Site B's main database name
    'username' =&gt; 'site_b_db_username',
    'password' =&gt; 'site_b_db_password',
    'prefix' =&gt; array(
        'default' =&gt; 'site_b_prefix_',    // Prefix for all tables in Site B's main database (specified above), other than for the tables specified below
        'role' =&gt; 'shared_db_name.shared_prefix_',              // Shared database name and prefix for the 'role' table
        'users' =&gt; 'shared_db_name.shared_prefix_',             // Shared database name and prefix for the 'users' table
        'authmap' =&gt; 'shared_db_name.shared_prefix_',           // Shared database name and prefix for the 'authmap' table
        'sessions' =&gt; 'shared_db_name.shared_prefix_',          // Shared database name and prefix for the 'sessions' table
        'profile_fields' =&gt; 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_fields' table
        'profile_values' =&gt; 'shared_db_name.shared_prefix_',    // Shared database name and prefix for the 'profile_values' table
    ),
    'host' =&gt; 'localhost',
    'port' =&gt; '3306',
    'driver' =&gt; 'mysql',
    'collation' =&gt; 'utf8mb4_general_ci',
);


As shown in the above code, under 'prefix' array, we can specify separate database and prefix for each different table used in the site. Other than those tables exclusively specified in the 'prefix' array, for all other tables, the prefix specified as 'default' shall be used.

In Drupal 8, user/role/session sharing is not as easy as in Drupal 7, because in Drupal 8, many of the informations, including the user roles, are part of a shared table (that shared table is meant for storing many different variable values, and roles are just part of that).