Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
267 lines (166 sloc) 11.2 KB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Filip Tepper</title>
<meta name="description" content="">
<link rel="stylesheet" href="/assets/main.css">
<link rel="canonical" href="/">
<link rel="alternate" type="application/rss+xml" title="Filip Tepper" href="/feed.xml">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Filip Tepper">
<meta name="twitter:description" content="">
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Bitter:400,700,400italic:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-275035-8"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'UA-275035-8');
</script>
</head>
<body>
<header class="site-header">
<div class="wrapper">
<a class="site-title" href="/">Filip Tepper</a>
<nav class="site-nav">
<a class="page-link" href="/about/">About</a>
</nav>
</div>
</header>
<main class="page-content" aria-label="Content">
<div class="wrapper">
<div class="home">
<ul class="post-list">
<li>
<header class="post-header">
<h1 class="post-title">
<a class="post-link" href="/2017/10/09/auto-scaling-dynamodb-tables-with-rubys-aws-sdk/">Auto scaling DynamoDB tables with Ruby&#39;s aws-sdk</a>
</h1>
<p class="post-meta">Oct 9, 2017</p>
</header>
<div class="post-content">
<p>Recently Amazon introduced <a href="https://aws.amazon.com/blogs/aws/new-auto-scaling-for-amazon-dynamodb/">DynamoDB auto scaling</a>, which we were very keen to try. Our current solution was flaky at best, and caused numerous issues with under- and overprovisioning.</p>
<p>Some of our DynamoDB tables are created dynamically - we use Ruby <code class="highlighter-rouge">aws-sdk</code> gem for that. To add autoscaling to already existing table follow this example, which sets desired capacity utilization to 75% for both reads and writes, with 100 as maximum capacity for reads, and 800 maximum capacity for writes.</p>
<div class="language-ruby highlighter-rouge"><pre class="highlight"><code><span class="n">client</span> <span class="o">=</span> <span class="no">Aws</span><span class="o">::</span><span class="no">ApplicationAutoScaling</span><span class="o">::</span><span class="no">Client</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span>
<span class="ss">region: </span><span class="no">ENV</span><span class="p">[</span><span class="s1">'AUTOSCALING_AWS_REGION'</span><span class="p">],</span>
<span class="ss">access_key_id: </span><span class="no">ENV</span><span class="p">[</span><span class="s1">'AUTOSCALING_AWS_KEY'</span><span class="p">],</span>
<span class="ss">secret_access_key: </span><span class="no">ENV</span><span class="p">[</span><span class="s1">'AUTOSCALING_AWS_SECRET'</span><span class="p">]</span>
<span class="p">)</span>
<span class="c1"># table name needs to prefixed with 'table/'</span>
<span class="n">resource_id</span> <span class="o">=</span> <span class="s1">'table/TABLE_NAME'</span>
<span class="n">target_options</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">resource_id: </span><span class="n">resource_id</span><span class="p">,</span>
<span class="c1"># replace '012345678901' with your account</span>
<span class="ss">role_arn: </span><span class="s1">'arn:aws:iam::012345678901:role/service-role/DynamoDBAutoscaleRole'</span><span class="p">,</span>
<span class="ss">service_namespace: </span><span class="s1">'dynamodb'</span>
<span class="p">}</span>
<span class="c1"># http://docs.aws.amazon.com/sdkforruby/api/Aws/ApplicationAutoScaling/Client.html#register_scalable_target-instance_method</span>
<span class="n">client</span><span class="p">.</span><span class="nf">register_scalable_target</span><span class="p">(</span>
<span class="n">target_options</span><span class="p">.</span><span class="nf">merge</span><span class="p">(</span>
<span class="ss">max_capacity: </span><span class="mi">100</span><span class="p">,</span>
<span class="ss">min_capacity: </span><span class="mi">1</span><span class="p">,</span>
<span class="ss">scalable_dimension: </span><span class="s1">'dynamodb:table:ReadCapacityUnits'</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">client</span><span class="p">.</span><span class="nf">register_scalable_target</span><span class="p">(</span>
<span class="n">target_options</span><span class="p">.</span><span class="nf">merge</span><span class="p">(</span>
<span class="ss">max_capacity: </span><span class="mi">800</span><span class="p">,</span>
<span class="ss">min_capacity: </span><span class="mi">1</span><span class="p">,</span>
<span class="ss">scalable_dimension: </span><span class="s1">'dynamodb:table:WriteCapacityUnits'</span><span class="p">,</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">policy_options</span> <span class="o">=</span> <span class="p">{</span>
<span class="ss">service_namespace: </span><span class="s1">'dynamodb'</span><span class="p">,</span>
<span class="ss">resource_id: </span><span class="n">resource_id</span><span class="p">,</span>
<span class="ss">policy_type: </span><span class="s1">'TargetTrackingScaling'</span><span class="p">,</span>
<span class="p">}</span>
<span class="c1"># http://docs.aws.amazon.com/sdkforruby/api/Aws/ApplicationAutoScaling/Client.html#put_scaling_policy-instance_method</span>
<span class="n">client</span><span class="p">.</span><span class="nf">put_scaling_policy</span><span class="p">(</span>
<span class="n">policy_options</span><span class="p">.</span><span class="nf">merge</span><span class="p">(</span>
<span class="ss">policy_name: </span><span class="s1">'dynamodb-read-autoscaling-TABLE_NAME'</span><span class="p">,</span>
<span class="ss">scalable_dimension: </span><span class="s1">'dynamodb:table:ReadCapacityUnits'</span><span class="p">,</span>
<span class="ss">target_tracking_scaling_policy_configuration: </span><span class="p">{</span>
<span class="ss">target_value: </span><span class="mi">75</span><span class="o">.</span><span class="mi">0</span><span class="p">,</span>
<span class="ss">predefined_metric_specification: </span><span class="p">{</span>
<span class="ss">predefined_metric_type: </span><span class="s1">'DynamoDBReadCapacityUtilization'</span>
<span class="p">},</span>
<span class="ss">scale_out_cooldown: </span><span class="mi">1</span><span class="p">,</span>
<span class="ss">scale_in_cooldown: </span><span class="mi">1</span>
<span class="p">}</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="n">client</span><span class="p">.</span><span class="nf">put_scaling_policy</span><span class="p">(</span>
<span class="n">policy_options</span><span class="p">.</span><span class="nf">merge</span><span class="p">(</span>
<span class="ss">policy_name: </span><span class="s1">'dynamodb-write-autoscaling-TABLE_NAME'</span><span class="p">,</span>
<span class="ss">scalable_dimension: </span><span class="s1">'dynamodb:table:WriteCapacityUnits'</span><span class="p">,</span>
<span class="ss">target_tracking_scaling_policy_configuration: </span><span class="p">{</span>
<span class="ss">target_value: </span><span class="mi">75</span><span class="o">.</span><span class="mi">0</span><span class="p">,</span>
<span class="ss">predefined_metric_specification: </span><span class="p">{</span>
<span class="ss">predefined_metric_type: </span><span class="s1">'DynamoDBWriteCapacityUtilization'</span>
<span class="p">},</span>
<span class="ss">scale_out_cooldown: </span><span class="mi">1</span><span class="p">,</span>
<span class="ss">scale_in_cooldown: </span><span class="mi">1</span>
<span class="p">}</span>
<span class="p">)</span>
<span class="p">)</span>
</code></pre>
</div>
</div>
</li>
<li>
<header class="post-header">
<h1 class="post-title">
<a class="post-link" href="/2017/09/29/faktura-vat-z-app-store/">Faktura VAT z App Store</a>
</h1>
<p class="post-meta">Sep 29, 2017</p>
</header>
<div class="post-content">
<p>Kupując aplikację za 5, 10, czy 30 zł nie myśli się o fakturze VAT, ale przed poważniejszymi zakupami w Mac App Store spróbowałem sprawdzić w jaki sposób można otrzymać poprawny dokument, którego przy pierwszej okazji nie zakwestionuje księgowość.</p>
<p>Mam nadzieję, że docenicie poświęcone 1,99zł na aplikację, z której nigdy nie skorzystam.</p>
<p>Przygodę zaczynamy na stronie <a href="https://reportaproblem.apple.com/">https://reportaproblem.apple.com/</a>. Dalej przechodzimy do zakładki Invoices.</p>
<p><img src="/images/2017-09-29/1.png" alt="Invoices" /></p>
<p>Znajdujemy na liście interesującą nas pozycję i oczywiście wybieramy Invoice.</p>
<p><img src="/images/2017-09-29/2.png" alt="Invoices" /></p>
<p>Coraz bliżej, więc tym razem szukamy VAT Invoices.</p>
<p><img src="/images/2017-09-29/3.png" alt="Invoices" /></p>
<p>Voilà! Jest miejsce na podanie numeru NIP i adresu email. Fakturę można od razu wydrukować lub wysłać emailem na wskazany adres.</p>
<p><img src="/images/2017-09-29/4.png" alt="Invoices" /></p>
<p>Po wysłaniu dokumentu do księgowości otrzymasz informację, że ta faktura nie pozwala na odliczenie podatku VAT. Równie dobrze można sobie te wszystkie kroki podarować.</p>
<p><em>climax</em></p>
<p>Chwytasz za telefon, dzwonisz na infolinię (800 702 322, choć teoretycznie dla biznesu numer to 800 702 328). Tam w dziale posprzedażowym prosisz o korektę faktury z zerowym podatkiem VAT.</p>
<p>Dla części oprogramowania możliwe jest też złożenie zamówienia bezpośrednio na infolinii, wtedy jest możliwość otrzymania poprawnej faktury od ręki (na przykład dla Final Cut czy Logic Pro).</p>
</div>
</li>
</ul>
<div class="pagination">
<a class="previous" href="/posts/2/">&laquo; Older</a>
</div>
</div>
</div>
</main>
<footer class="site-footer">
<div class="wrapper">
<p>
&copy; - Powered by <a href="https://jekyllrb.com">Jekyll</a> &amp; <a href="https://github.com/yous/whiteglass">whiteglass</a> - Subscribe via <a href="/feed.xml">RSS</a>
</p>
</div>
</footer>
</body>
</html>