27 Temmuz 2021 Salı

ACID - Dirty Read ve Dirty Write - Commitlenmemiş Veriye Erişmek

Giriş
Şeklen şöyle

SQL Server için şeklen şöyle
Dirty Read
Kısaca commit'lenmemiş bir transaction'a ait veriyi okumak anlamına gelir. Bizim transaction'ımız diğer transaction'a ait veriyi okur, ancak daha sonra diğer transaction rollback yapmaya karar verir. Bu durumda Dirty Read olur. Açıklaması şöyle
A dirty read happens when a transaction is allowed to read the uncommitted changes of some other concurrent transaction. Taking a business decision on a value that has not been committed is risky because uncommitted changes might get rolled back.
Dirty Write
Bir  transaction, bir başka transaction'a ait veriyi de yazar, ancak daha sonra diğer transaction rollback yapmaya karar verir. Bu durumda Dirty Write olur 

26 Temmuz 2021 Pazartesi

Content Delivery Network - CDN

Giriş
Açıklaması şöyle. CDN sık kullanılan şeyleri cache'ler
A CDN is a network of servers that are distributed around the world, and are used to deliver content to users based on their location.

When a user requests content from a CDN, the closest server to the user will deliver the content, rather than having the user’s request be routed to the origin server. The content is then cached on the CDN server, so that if another user in the same location requests the same content, it can be quickly delivered from the cache.
Açıklaması şöyle. Cache'lenen şey herhangi bir şey olabilir. 
They allow websites to cache frequently accessed assets — such as pictures, videos, or JavaScript files — to make the website more performant and avoid downtime.
Açıklaması şöyle
Also, there are generally two kinds of CDNs conceptually
1. Push CDN: You are responsible to upload data to the CDN servers
2. Pull CDN: The CDN will pull data from your servers (origin servers)





Google Cloud

Giriş
AWS ve Google Cloud karşılaştırması şeklen şöyle

Bir başka yazı burada

Google Cloud Dataflow
Serverless stream ve batch processing içindir.

Google Cloud Shell
Linux bilgisayar gibi. python3, git, docker gibi komutlar mevcut. 

gcloud komutu
gcloud komutu yazısına taşıdım

MemoryStore
Açıklaması şöyle
Redis is a popular open source in memory database. It is available as a managed service on AWS (Elasticache) and Google Cloud (Memorystore).
Push Notification
Açıklaması şöyle
Notifications of Whatsapp and Reddit are triggered by push notifications sent from Google servers, received by Google Play Services, a system app which always runs in background.

Depending on the received push notification type such a push notification can be displayed directly without even starting the app it is targeting or the push message is delivered to the app (which is automatically started if it is not already running) and the app can then "translate" the push message into a notification (in case of Whatsapp this require e.g. decryption of the received message or even fetching additional data from Whatsapp servers).
Bigtable
Google Cloud Veri Tabanları yazısına taşıdım

BigQuery
Google Cloud Veri Tabanları yazısına taşıdım


Pub/Sub
Google Cloud Pub/Sub yazısına taşıdım

Google Cloud Storage
Google Cloud Storage yazısına taşıdım

Google Cloud Functions
Serverless ve event driven geliştirme imkanı sağlar. AWS karşılığı Lambda, Azure karşılığı ise Azure Functions

Google Cloud WorkFlows
Açıklaması şöyle
A cloud-based workflow engine managed by Google Cloud. Workflows can be defined in either YAML or JSON format. Furthermore, the orchestrator uses HTTP to interact with the tasks.
Google Kubernetes Engine (GKE)




Http Long Polling

Giriş
Açıklaması şöyle
In long polling, clients can request information from the server to expect that the server may not respond immediately. If the server has no new data for the client when the poll is received, instead of sending an empty response, the server holds the request open and waits for response information to become available. Once it does have new information, the server immediately sends the response to the client, completing the open request. Upon receipt of the server response, the client can immediately issue another server request for future updates. This gives a lot of improvements in latencies, throughputs, and performance. However, the long polling request can timeout or receive a disconnect from the server. In that case, the client has to open a new request.

23 Temmuz 2021 Cuma

Trigonometrik Fonksiyonlar - PI Sayısı

Hazır Sabitler
Örnek - C ve C++
Şöyle yaparız
#include <math.h>
M_PI şeklinde kullanılır
Örnek - C++ - 20
Şöyle yaparız
std::numbers::pi
Kendimiz Hesaplarsak
Örnek - C++
Şöyle yaparız
static const double PI = std::atan(1) * 4;
Örnek - C#
Şöyle hesaplanabilir.

Kod olarak şöyle yaparız. Bölümdeki böleni hep 2 artırırız. Bölme işlemi bir artı bir de eksi olacak işareti ile toplama eklenir.
double number = 0;
double pi;
int i = 1;

do 
{
  if ((i/2) % 2 == 0)
  {
    number += (double)(1) / i;
  }
  else
  {
    number -= (double)(1) / i;
  }
  pi = 4 * number;
  i += 2;
} while (Math.Round(pi,5) != 3.14159);

Trigonometrik Fonksiyonlar - Sinüs

Giriş
Sinüs temel trigonometrik fonksiyonlardan birisi. sin (sinüs) fonksiyonu ile dikkat edilmesi gereken nokta, sin (PI) çağrısı sonucunda,  PI sayısı floating sayı olarak tam temsil edilemediğinden 0'ı vermeyebilir.

Çıktı Birimi
Sinüs radyan cinsinden çalışır. Dolayısıyla şöyle yapmak gerekir.
public static double sin(double angle){    
  angle = Math.toRadians(angle);
  return Math.sin(angle);
}
Sinüs  Hesaplama

Örnek

sinüsü hesaplamak için Taylor Serisi kullanılabilir.

Örnek
Tablo kullanarak hesaplanabilir.


22 Temmuz 2021 Perşembe

HTTP/3 - HTTP over QUIC

Tarayıcı Desteği
Tarayıcımızın HTTP/3 destekleyip desteklemediğini görmek için  quic.nginx.org adresine gidilebilir.

TCP Kullanmıyor, QUIC Kullanıyor
Açıklaması şöyle.
Instead of TCP, HTTP/3 uses a new protocol, developed in 2012 by Google, called QUIC (pronounced “quick”).
QUIC'in Özellikleri
Bazı özellikleri şöyle
- Instead of TCP, HTTP/3 uses a new protocol, QUIC, developed by Google in 2012. QUIC runs over UDP, the User Datagram Protocol.
- QUIC provides native multiplexing, and lost packets only impact the streams where data has been lost. This resolves the head-of-line blocking issue in HTTP/2.
- QUIC provides flow control for stream data and all HTTP/3 frame types that are sent on streams. Therefore, all frame headers and payloads are subject to flow control.
- The request and response headers are compressed by QPACK instead of HPACK in HTTP/2.
- Several HTTP/3 frames are used to manage server push.
Native Multiplexing
Bu sayede sayfayı paralel yüklemek mümkün. Açıklaması şöyle.
Before HTTP/2, browsers could only send one request to the server at a time. This made website loading significantly slower because the browser only loaded one asset, like CSS or JavaScript, at a time. HTTP/2 introduced the ability to load more than one asset at a time, but TCP was not made for this. If one of the requests failed, TCP would make the browser redo all the requests. Because TCP was removed in HTTP/3 and replaced by QUIC, HTTP/3 solved this problem. With HTTP/3, the browser only needs to redo the failed request. Because of this, HTTP/3 is faster and more reliable.
TLS
Açıklaması şöyle. QUIC protokolü de TLS kullanıyor
HTTP/3 optimizes the “handshake” that allows browsers HTTP requests to be encrypted. QUIC combines the initial connection with a TLS handshake, making it secure by default and faster.