Remove use of ```, which doesn't render well
This commit is contained in:
@@ -31,9 +31,9 @@
|
|||||||
<li>Have everyone close the applications on their computers (but not log out) for a moment. Watch the activity lights on your switches/routers/access points. They should be mostly solid, with perhaps one or two blinks per second. Got a light that’s still flashing like mad? You might have a virus infection and a computer spewing out spam or virus attacks. Use the activity lights to trace down the source and figure out what’s causing it. Remember: virus scanners don’t work. Reinstall the machine, give the user a Limited account (as opposed to “Computer Administrator”), and refuse to install any software for them unless it’s critical to their job.</li>
|
<li>Have everyone close the applications on their computers (but not log out) for a moment. Watch the activity lights on your switches/routers/access points. They should be mostly solid, with perhaps one or two blinks per second. Got a light that’s still flashing like mad? You might have a virus infection and a computer spewing out spam or virus attacks. Use the activity lights to trace down the source and figure out what’s causing it. Remember: virus scanners don’t work. Reinstall the machine, give the user a Limited account (as opposed to “Computer Administrator”), and refuse to install any software for them unless it’s critical to their job.</li>
|
||||||
<li><p>Make sure that you only have one DHCP server on your network. More than one will likely cause some machines to get incorrect IP addresses and be unable to go anywhere. Testing for this is a little difficult. First, burn an Ubuntu CD. Reboot with the new CD in your drive, and your system should boot into the Ubuntu environment. Open a terminal window (Applications -> Accessories -> Terminal) and type:</p>
|
<li><p>Make sure that you only have one DHCP server on your network. More than one will likely cause some machines to get incorrect IP addresses and be unable to go anywhere. Testing for this is a little difficult. First, burn an Ubuntu CD. Reboot with the new CD in your drive, and your system should boot into the Ubuntu environment. Open a terminal window (Applications -> Accessories -> Terminal) and type:</p>
|
||||||
|
|
||||||
<p><code>sudo ifdown eth0
|
<pre><code>sudo ifdown eth0
|
||||||
sudo dhclient eth0
|
sudo dhclient eth0
|
||||||
</code></p>
|
</code></pre>
|
||||||
|
|
||||||
<p>You should see one or more lines starting with DHCPOFFER and telling you where the offer came from. If you see more than one source of offers, you need to eliminate extra DHCP servers.</p></li>
|
<p>You should see one or more lines starting with DHCPOFFER and telling you where the offer came from. If you see more than one source of offers, you need to eliminate extra DHCP servers.</p></li>
|
||||||
</ol>
|
</ol>
|
||||||
@@ -45,17 +45,20 @@ sudo dhclient eth0
|
|||||||
<ol>
|
<ol>
|
||||||
<li><p>You’ll need the exact hostname of the service you’re trying to access. For example, if it’s slow when you try to visit http://firestuff.org/ in a web browser, then firestuff.org is the hostname. Pull out your Ubuntu CD again, and in a terminal, type:</p>
|
<li><p>You’ll need the exact hostname of the service you’re trying to access. For example, if it’s slow when you try to visit http://firestuff.org/ in a web browser, then firestuff.org is the hostname. Pull out your Ubuntu CD again, and in a terminal, type:</p>
|
||||||
|
|
||||||
<p><code>host firestuff.org</code></p>
|
<pre><code>host firestuff.org
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
<p>(obviously, replace firestuff.org with the hostname you’re concerned with)</p>
|
<p>(obviously, replace firestuff.org with the hostname you’re concerned with)</p>
|
||||||
|
|
||||||
<p>This converts firestuff.org into an IP address using DNS. It should take less than a second to complete. If it takes much longer, either your ISP’s DNS servers or those that provide the firestuff.org data may have problems. To narrow it down, try:</p>
|
<p>This converts firestuff.org into an IP address using DNS. It should take less than a second to complete. If it takes much longer, either your ISP’s DNS servers or those that provide the firestuff.org data may have problems. To narrow it down, try:</p>
|
||||||
|
|
||||||
<p><code>host www.google.com</code></p>
|
<pre><code>host www.google.com
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
<p>If that returns instantly, then it’s the firestuff.org DNS servers that have problems; contact the administrator there. If the Google test also takes a long time, your ISP has a DNS server problem, or you have the wrong DNS servers configured in your DHCP server. Type:</p>
|
<p>If that returns instantly, then it’s the firestuff.org DNS servers that have problems; contact the administrator there. If the Google test also takes a long time, your ISP has a DNS server problem, or you have the wrong DNS servers configured in your DHCP server. Type:</p>
|
||||||
|
|
||||||
<p><code>cat /etc/resolv.conf</code></p>
|
<pre><code>cat /etc/resolv.conf
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
<p>then call your ISP and read it to them. If the numbers aren’t what your ISP says they should be, reconfigure your DHCP server. If they are, ask what the holdup is.</p></li>
|
<p>then call your ISP and read it to them. If the numbers aren’t what your ISP says they should be, reconfigure your DHCP server. If they are, ask what the holdup is.</p></li>
|
||||||
<li>Try the same thing from other computers on your network.</li>
|
<li>Try the same thing from other computers on your network.</li>
|
||||||
@@ -63,7 +66,8 @@ sudo dhclient eth0
|
|||||||
<li>Try plugging the same computer into different points in the network. Generally, it helps to move it up to where it has to traverse less devices (i.e. towards the “Internet”) until the problem stops. Then move it back down again, to make sure that the issue wasn’t temporary and your solution a fluke.</li>
|
<li>Try plugging the same computer into different points in the network. Generally, it helps to move it up to where it has to traverse less devices (i.e. towards the “Internet”) until the problem stops. Then move it back down again, to make sure that the issue wasn’t temporary and your solution a fluke.</li>
|
||||||
<li><p>Open your Ubuntu terminal and run:</p>
|
<li><p>Open your Ubuntu terminal and run:</p>
|
||||||
|
|
||||||
<p><code>mtr firestuff.org</code></p>
|
<pre><code>mtr firestuff.org
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
<p>You’ll want to make the window a bit bigger. This application gives you real time timing data following the route from your network to firestuff.org. Watch the average times and loss percentages. Nothing above 0% is really acceptable loss; your ISP will probably claim that it is, but they’re lying. Remember that the numbers are cumulative; if hop 3 is dropping packets, those drops will effect hop 3 and everything beyond it. However, it’s really hop 3’s problem, and if hop 6 has a problem, it’ll be hard to see until you get the closer issue cleared up.</p></li>
|
<p>You’ll want to make the window a bit bigger. This application gives you real time timing data following the route from your network to firestuff.org. Watch the average times and loss percentages. Nothing above 0% is really acceptable loss; your ISP will probably claim that it is, but they’re lying. Remember that the numbers are cumulative; if hop 3 is dropping packets, those drops will effect hop 3 and everything beyond it. However, it’s really hop 3’s problem, and if hop 6 has a problem, it’ll be hard to see until you get the closer issue cleared up.</p></li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -27,12 +27,12 @@
|
|||||||
<li><p>Don’t store event-based data as one row per event. If you record page views or clicks in the database, aggregate that data into one row per hour, or per day. You can keep logs of events outside of the database in case you need to change aggregation and re-generate historical data, but don’t keep every event in a hot table.</p></li>
|
<li><p>Don’t store event-based data as one row per event. If you record page views or clicks in the database, aggregate that data into one row per hour, or per day. You can keep logs of events outside of the database in case you need to change aggregation and re-generate historical data, but don’t keep every event in a hot table.</p></li>
|
||||||
<li><p>Stop using AUTO_INCREMENT. Instead, keep a table <a href="http://www.reddit.com/r/mysql/comments/jcw8o/database_best_practices_for_future_scalability/c2b2o4v">IdSequences</a>, and do something like: </p>
|
<li><p>Stop using AUTO_INCREMENT. Instead, keep a table <a href="http://www.reddit.com/r/mysql/comments/jcw8o/database_best_practices_for_future_scalability/c2b2o4v">IdSequences</a>, and do something like: </p>
|
||||||
|
|
||||||
<p><code>BEGIN;
|
<pre><code>BEGIN;
|
||||||
UPDATE IdSequences SET LastId=LAST_INSERT_ID(LastId+Increment)
|
UPDATE IdSequences SET LastId=LAST_INSERT_ID(LastId+Increment)
|
||||||
WHERE TableName='A' AND ColumnName='b';
|
WHERE TableName='A' AND ColumnName='b';
|
||||||
INSERT INTO A (b, c) VALUES (LAST_INSERT_ID(), ‘foo’);
|
INSERT INTO A (b, c) VALUES (LAST_INSERT_ID(), ‘foo’);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
</code></p>
|
</code></pre>
|
||||||
|
|
||||||
<p>This lets you change IdSequences later to modify your sharding scheme.</p></li>
|
<p>This lets you change IdSequences later to modify your sharding scheme.</p></li>
|
||||||
<li><p>Create an empty shard (new database, same schema, no data) and add test rows. Teach your application to choose which shard to talk to. This will require some method to look up a shard for the root of each hierarchy; keep all data linked to a particular root on the same shard, so you can JOIN it. At its simplest, the lookup can be (ID mod NumShards). If you have uneven shard growth, you may need an indirection table to map from virtual shard (determined by modular division with a large divisor) to physical database.</p></li>
|
<li><p>Create an empty shard (new database, same schema, no data) and add test rows. Teach your application to choose which shard to talk to. This will require some method to look up a shard for the root of each hierarchy; keep all data linked to a particular root on the same shard, so you can JOIN it. At its simplest, the lookup can be (ID mod NumShards). If you have uneven shard growth, you may need an indirection table to map from virtual shard (determined by modular division with a large divisor) to physical database.</p></li>
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
<li>Don't run one-off executables against your database. Instead, have the executable print out SQL that it would have run to update the database. If something goes wrong, you don't have to model the behavior of the program; you can just look at the SQL.</li>
|
<li>Don't run one-off executables against your database. Instead, have the executable print out SQL that it would have run to update the database. If something goes wrong, you don't have to model the behavior of the program; you can just look at the SQL.</li>
|
||||||
<li>Check the SQL files into source control somewhere. Manual changes tend to breed more manual changes to fix the fixes, so you never know when you'll want a record of what you twiddled in the past.</li>
|
<li>Check the SQL files into source control somewhere. Manual changes tend to breed more manual changes to fix the fixes, so you never know when you'll want a record of what you twiddled in the past.</li>
|
||||||
<li>Include all fields from the primary key in the WHERE clause. This ensures that each statement only modifies one row. Even if this results in a huge list of changes, at least you know exactly what changed.</li>
|
<li>Include all fields from the primary key in the WHERE clause. This ensures that each statement only modifies one row. Even if this results in a huge list of changes, at least you know exactly what changed.</li>
|
||||||
<li>Include as many additional gating clauses as possible, linked with AND. For example, if you have a table of products and you want to set the price to 0.99 for everything that is currently set to 1.00, do:
|
<li><p>Include as many additional gating clauses as possible, linked with AND. For example, if you have a table of products and you want to set the price to 0.99 for everything that is currently set to 1.00, do:</p>
|
||||||
<code>UPDATE Products SET Price=0.99 WHERE ProductId=2762 AND Price=1.00;
|
|
||||||
</code>
|
<pre><code>UPDATE Products SET Price=0.99 WHERE ProductId=2762 AND Price=1.00;
|
||||||
This ensures that if something else changes Price just before you run your change, you don't destroy that update.</li>
|
</code></pre>
|
||||||
|
|
||||||
|
<p>This ensures that if something else changes Price just before you run your change, you don't destroy that update.</p></li>
|
||||||
<li>Record the number of rows affected by each statement, in case something unexpected happens.</li>
|
<li>Record the number of rows affected by each statement, in case something unexpected happens.</li>
|
||||||
<li>Use transactions sensibly. Overly huge grouping of statements can block replication, but consider whether your changes will be toxic if partially applied.</li>
|
<li>Use transactions sensibly. Overly huge grouping of statements can block replication, but consider whether your changes will be toxic if partially applied.</li>
|
||||||
<li>Stop running changes on errors or warnings and let a human examine the output. Warnings like string truncation can be a sign of a broken change.</li>
|
<li>Stop running changes on errors or warnings and let a human examine the output. Warnings like string truncation can be a sign of a broken change.</li>
|
||||||
|
|||||||
@@ -26,9 +26,8 @@ You get what you pay for
|
|||||||
1. Have everyone close the applications on their computers (but not log out) for a moment. Watch the activity lights on your switches/routers/access points. They should be mostly solid, with perhaps one or two blinks per second. Got a light that’s still flashing like mad? You might have a virus infection and a computer spewing out spam or virus attacks. Use the activity lights to trace down the source and figure out what’s causing it. Remember: virus scanners don’t work. Reinstall the machine, give the user a Limited account (as opposed to “Computer Administrator”), and refuse to install any software for them unless it’s critical to their job.
|
1. Have everyone close the applications on their computers (but not log out) for a moment. Watch the activity lights on your switches/routers/access points. They should be mostly solid, with perhaps one or two blinks per second. Got a light that’s still flashing like mad? You might have a virus infection and a computer spewing out spam or virus attacks. Use the activity lights to trace down the source and figure out what’s causing it. Remember: virus scanners don’t work. Reinstall the machine, give the user a Limited account (as opposed to “Computer Administrator”), and refuse to install any software for them unless it’s critical to their job.
|
||||||
1. Make sure that you only have one DHCP server on your network. More than one will likely cause some machines to get incorrect IP addresses and be unable to go anywhere. Testing for this is a little difficult. First, burn an Ubuntu CD. Reboot with the new CD in your drive, and your system should boot into the Ubuntu environment. Open a terminal window (Applications -> Accessories -> Terminal) and type:
|
1. Make sure that you only have one DHCP server on your network. More than one will likely cause some machines to get incorrect IP addresses and be unable to go anywhere. Testing for this is a little difficult. First, burn an Ubuntu CD. Reboot with the new CD in your drive, and your system should boot into the Ubuntu environment. Open a terminal window (Applications -> Accessories -> Terminal) and type:
|
||||||
|
|
||||||
```sudo ifdown eth0
|
sudo ifdown eth0
|
||||||
sudo dhclient eth0
|
sudo dhclient eth0
|
||||||
```
|
|
||||||
|
|
||||||
You should see one or more lines starting with DHCPOFFER and telling you where the offer came from. If you see more than one source of offers, you need to eliminate extra DHCP servers.
|
You should see one or more lines starting with DHCPOFFER and telling you where the offer came from. If you see more than one source of offers, you need to eliminate extra DHCP servers.
|
||||||
|
|
||||||
@@ -38,17 +37,17 @@ By far the most common network issue seems to be nebulous “slowness”. We’l
|
|||||||
|
|
||||||
1. You’ll need the exact hostname of the service you’re trying to access. For example, if it’s slow when you try to visit http://firestuff.org/ in a web browser, then firestuff.org is the hostname. Pull out your Ubuntu CD again, and in a terminal, type:
|
1. You’ll need the exact hostname of the service you’re trying to access. For example, if it’s slow when you try to visit http://firestuff.org/ in a web browser, then firestuff.org is the hostname. Pull out your Ubuntu CD again, and in a terminal, type:
|
||||||
|
|
||||||
```host firestuff.org```
|
host firestuff.org
|
||||||
|
|
||||||
(obviously, replace firestuff.org with the hostname you’re concerned with)
|
(obviously, replace firestuff.org with the hostname you’re concerned with)
|
||||||
|
|
||||||
This converts firestuff.org into an IP address using DNS. It should take less than a second to complete. If it takes much longer, either your ISP’s DNS servers or those that provide the firestuff.org data may have problems. To narrow it down, try:
|
This converts firestuff.org into an IP address using DNS. It should take less than a second to complete. If it takes much longer, either your ISP’s DNS servers or those that provide the firestuff.org data may have problems. To narrow it down, try:
|
||||||
|
|
||||||
```host www.google.com```
|
host www.google.com
|
||||||
|
|
||||||
If that returns instantly, then it’s the firestuff.org DNS servers that have problems; contact the administrator there. If the Google test also takes a long time, your ISP has a DNS server problem, or you have the wrong DNS servers configured in your DHCP server. Type:
|
If that returns instantly, then it’s the firestuff.org DNS servers that have problems; contact the administrator there. If the Google test also takes a long time, your ISP has a DNS server problem, or you have the wrong DNS servers configured in your DHCP server. Type:
|
||||||
|
|
||||||
```cat /etc/resolv.conf```
|
cat /etc/resolv.conf
|
||||||
|
|
||||||
then call your ISP and read it to them. If the numbers aren’t what your ISP says they should be, reconfigure your DHCP server. If they are, ask what the holdup is.
|
then call your ISP and read it to them. If the numbers aren’t what your ISP says they should be, reconfigure your DHCP server. If they are, ask what the holdup is.
|
||||||
1. Try the same thing from other computers on your network.
|
1. Try the same thing from other computers on your network.
|
||||||
@@ -56,7 +55,7 @@ By far the most common network issue seems to be nebulous “slowness”. We’l
|
|||||||
1. Try plugging the same computer into different points in the network. Generally, it helps to move it up to where it has to traverse less devices (i.e. towards the “Internet”) until the problem stops. Then move it back down again, to make sure that the issue wasn’t temporary and your solution a fluke.
|
1. Try plugging the same computer into different points in the network. Generally, it helps to move it up to where it has to traverse less devices (i.e. towards the “Internet”) until the problem stops. Then move it back down again, to make sure that the issue wasn’t temporary and your solution a fluke.
|
||||||
1. Open your Ubuntu terminal and run:
|
1. Open your Ubuntu terminal and run:
|
||||||
|
|
||||||
```mtr firestuff.org```
|
mtr firestuff.org
|
||||||
|
|
||||||
You’ll want to make the window a bit bigger. This application gives you real time timing data following the route from your network to firestuff.org. Watch the average times and loss percentages. Nothing above 0% is really acceptable loss; your ISP will probably claim that it is, but they’re lying. Remember that the numbers are cumulative; if hop 3 is dropping packets, those drops will effect hop 3 and everything beyond it. However, it’s really hop 3’s problem, and if hop 6 has a problem, it’ll be hard to see until you get the closer issue cleared up.
|
You’ll want to make the window a bit bigger. This application gives you real time timing data following the route from your network to firestuff.org. Watch the average times and loss percentages. Nothing above 0% is really acceptable loss; your ISP will probably claim that it is, but they’re lying. Remember that the numbers are cumulative; if hop 3 is dropping packets, those drops will effect hop 3 and everything beyond it. However, it’s really hop 3’s problem, and if hop 6 has a problem, it’ll be hard to see until you get the closer issue cleared up.
|
||||||
|
|
||||||
|
|||||||
@@ -36,12 +36,11 @@ Then, things that cost development time, in increasing order of complexity:
|
|||||||
|
|
||||||
1. Stop using AUTO\_INCREMENT. Instead, keep a table [IdSequences](http://www.reddit.com/r/mysql/comments/jcw8o/database_best_practices_for_future_scalability/c2b2o4v), and do something like:
|
1. Stop using AUTO\_INCREMENT. Instead, keep a table [IdSequences](http://www.reddit.com/r/mysql/comments/jcw8o/database_best_practices_for_future_scalability/c2b2o4v), and do something like:
|
||||||
|
|
||||||
```BEGIN;
|
BEGIN;
|
||||||
UPDATE IdSequences SET LastId=LAST_INSERT_ID(LastId+Increment)
|
UPDATE IdSequences SET LastId=LAST_INSERT_ID(LastId+Increment)
|
||||||
WHERE TableName='A' AND ColumnName='b';
|
WHERE TableName='A' AND ColumnName='b';
|
||||||
INSERT INTO A (b, c) VALUES (LAST_INSERT_ID(), ‘foo’);
|
INSERT INTO A (b, c) VALUES (LAST_INSERT_ID(), ‘foo’);
|
||||||
COMMIT;
|
COMMIT;
|
||||||
```
|
|
||||||
|
|
||||||
This lets you change IdSequences later to modify your sharding scheme.
|
This lets you change IdSequences later to modify your sharding scheme.
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ It's a great goal to avoid making manual changes to your database. It never work
|
|||||||
1. Check the SQL files into source control somewhere. Manual changes tend to breed more manual changes to fix the fixes, so you never know when you'll want a record of what you twiddled in the past.
|
1. Check the SQL files into source control somewhere. Manual changes tend to breed more manual changes to fix the fixes, so you never know when you'll want a record of what you twiddled in the past.
|
||||||
1. Include all fields from the primary key in the WHERE clause. This ensures that each statement only modifies one row. Even if this results in a huge list of changes, at least you know exactly what changed.
|
1. Include all fields from the primary key in the WHERE clause. This ensures that each statement only modifies one row. Even if this results in a huge list of changes, at least you know exactly what changed.
|
||||||
1. Include as many additional gating clauses as possible, linked with AND. For example, if you have a table of products and you want to set the price to 0.99 for everything that is currently set to 1.00, do:
|
1. Include as many additional gating clauses as possible, linked with AND. For example, if you have a table of products and you want to set the price to 0.99 for everything that is currently set to 1.00, do:
|
||||||
```UPDATE Products SET Price=0.99 WHERE ProductId=2762 AND Price=1.00;
|
|
||||||
```
|
UPDATE Products SET Price=0.99 WHERE ProductId=2762 AND Price=1.00;
|
||||||
|
|
||||||
This ensures that if something else changes Price just before you run your change, you don't destroy that update.
|
This ensures that if something else changes Price just before you run your change, you don't destroy that update.
|
||||||
1. Record the number of rows affected by each statement, in case something unexpected happens.
|
1. Record the number of rows affected by each statement, in case something unexpected happens.
|
||||||
1. Use transactions sensibly. Overly huge grouping of statements can block replication, but consider whether your changes will be toxic if partially applied.
|
1. Use transactions sensibly. Overly huge grouping of statements can block replication, but consider whether your changes will be toxic if partially applied.
|
||||||
|
|||||||
Reference in New Issue
Block a user