diff --git a/core/modules/statistics/statistics.install b/core/modules/statistics/statistics.install
index c0d0a6f..ac68d30 100644
--- a/core/modules/statistics/statistics.install
+++ b/core/modules/statistics/statistics.install
@@ -154,3 +154,12 @@ function statistics_update_8001() {
     array('primary key' => array('nid'))
   );
 }
+
+/**
+ * Convert variables to state.
+ */
+function statistics_update_8002() {
+  update_variables_to_state(array(
+    'node_cron_views_scale' => 'statistics.node_views_scale',
+  ));
+}
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index f11f3ed..77b6f35 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -437,7 +437,7 @@ function statistics_ranking() {
         ),
         // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
         'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
-        'arguments' => array(':scale' => variable_get('node_cron_views_scale', 0)),
+        'arguments' => array(':scale' => state()->get('statistics.node_views_scale') ?: 0),
       ),
     );
   }
@@ -447,7 +447,7 @@ function statistics_ranking() {
  * Implements hook_update_index().
  */
 function statistics_update_index() {
-  variable_set('node_cron_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
+  state()->set('statistics.node_views_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
 }
 
 /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
index fbd754f..ca8df13 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
@@ -47,6 +47,10 @@ public function testSystemVariableUpgrade() {
       'value' => 1304208000,
       'variable_name' => 'update_last_email_notification',
     );
+    $expected_state['statistics.node_views_scale'] = array(
+      'value' => 1.0 / 2000,
+      'variable_name' => 'node_cron_views_scale',
+    );
 
     foreach ($expected_state as $name => $data) {
       $this->assertIdentical(state()->get($name), $data['value']);
diff --git a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
index 47c86f2..1643e8b 100644
--- a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
+++ b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
@@ -23,3 +23,7 @@
   ->key(array('name' => 'node_access_needs_rebuild'))
   ->fields(array('value' => serialize(TRUE)))
   ->execute();
+db_merge('variable')
+  ->key(array('name' => 'node_cron_views_scale'))
+  ->fields(array('value' => 1.0 / 2000))
+  ->execute();
