TECH |
Engadget Japanese |
Apple Storeの初売りスタート、Apple Gift Cardや「寅年」限定のAirTagがもらえるキャンペーンも |
https://japanese.engadget.com/apple-store-2022-012522105.html
|
airtag |
2022-01-02 01:25:22 |
TECH |
Engadget Japanese |
これひとつでお出かけOK。財布が一体になった「本革サコッシュウォレット」 |
https://japanese.engadget.com/sacoche-wallet-012501576.html
|
|
2022-01-02 01:25:01 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
適切なヒストグラムの描き方 |
https://qiita.com/StrawBerryMoon/items/ea01f7f122f437e3aa6d
|
作者はbinの数を指定した場合に思うようjなヒストグラムにならないと思ったのでしょうが以下のようにbinを階級の区切り値ベクトルで定義すれば思うような簡単にきれいなヒストグラムが書けます。 |
2022-01-02 10:57:56 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
【Nuxt.js×microCMS】診断機能実装①ユーザーの選択に応じて診断結果をmicroCMSから取得する |
https://qiita.com/Yudai_35_/items/086aa53701bdc9f2f37f
|
【Nuxtjs×microCMS】診断機能実装①ユーザーの選択に応じて診断結果をmicroCMSから取得するはじめにこんにちは今回は【Nuxtjs×microCMS】診断機能実装①ユーザーの選択に応じて診断結果をmicroCMSからの取得についてアウトプットしていきます今回の内容は以前記事にまとめた【Nuxtjs】ボタンを押したらデータ値をとる色が変わる方法の内容の続きにあたる実装内容になっております対象・診断アプリを作りたい方・ユーザーの選択に応じて表示させるものをコントロールしたい方・【Nuxtjs】ボタンを押したらデータ値をとる色が変わる方法までの内容がお済みの方参考microCMS公式サイトはこちら使用環境使用技術バージョンnuxtjsnuxtmicrocmsmodulenuxtjstailwindcss使用ファイル概要ファイル名概要pagesdiagnosevue診断ページ実装事前説明【Nuxtjs】ボタンを押したらデータ値をとる色が変わる方法ではQの実装しか記事にしていませんが、今回はQQまであります。 |
2022-01-02 10:59:42 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
typescriptの型エラーについてです。 |
https://teratail.com/questions/376326?rss=all
|
typescriptの型エラーについてです。 |
2022-01-02 10:59:42 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
ERROR 2005 (HY000): Unknown MySQL server host 'db' (-3)を解決したい |
https://teratail.com/questions/376325?rss=all
|
ERRORHYUnknownMySQLserverhostxdbxを解決したいdockerのdbコンテナーが起動してもすぐに止まるエラーが解決できずにいます。 |
2022-01-02 10:56:42 |
Program |
[全てのタグ]の新着質問一覧|teratail(テラテイル) |
IAnimatableのApplyAnimationClockの実装法について |
https://teratail.com/questions/376324?rss=all
|
IAnimatableのApplyAnimationClockの実装法についてWPFで使用するクラスを作成し、そのクラスの依存関係プロパティの値にDoubleAnimationから作成したClockを適用したいと思っていますが、ApplyAnimationClockの実装方法で躓きました。 |
2022-01-02 10:37:27 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
【AWS】S3 CLI オブジェクトにタグをつける方法 |
https://qiita.com/tomo-IR/items/8e160f3487dd869b281f
|
解決できたコマンドまずはオブジェクトをSにアップロードし、アップロードしたオブジェクトにタグをつけるというステップが必要でした。 |
2022-01-02 10:32:30 |
海外TECH |
Ars Technica |
HBO Max rings in a raunchy new year with Peacemaker red band trailer |
https://arstechnica.com/?p=1822998
|
peacemaker |
2022-01-02 01:46:06 |
海外TECH |
DEV Community |
System Design Interview Question: Designing a URL Shortening Service |
https://dev.to/arslan_ah/system-design-interview-question-designing-a-url-shortening-service-4029
|
System Design Interview Question Designing a URL Shortening ServiceHow to design a URL shortening service like TinyURL Software engineers usually struggle with system design interviews partly due to their lack of experience developing large scale systems and partly due to the unstructured nature of system design interviews Even advanced and experienced developers find system design interviews challenging since the design questions are open ended and have no standard answer To help with that in my previous post we discussed a step by step approach for solving system design interview questions Let s follow that approach to solve a classical system design question Designing a URL shortening service like TinyURL Question Statement Let s design a URL shortening service like TinyURL This service will provide short aliases redirecting to long URLs Why do we need URL shortening URL shortening is used to create shorter aliases for long URLs Let s call these shortened aliases “short links Users are redirected to the original URL when they hit these short links Short links save a lot of space when displayed printed messaged or tweeted Additionally users are less likely to mistype shorter URLs For example when we shortened this page through TinyURL We got The shortened URL is nearly one third the size of the actual URL URL shortening is used to optimize links across devices track individual links to analyze audience measure ad campaigns performance or hide affiliated original URLs If you haven t used tinyurl com before please try creating a new shortened URL and spend some time going through the various options their service offers This will help you a lot in understanding this chapter Requirements and Goals of the SystemOur URL shortening system should meet the following requirements Functional Requirements Given a URL our service should generate a shorter and unique alias of it This is called a short link This link should be short enough to be easily copied and pasted into applications When users access a short link our service should redirect them to the original link Users should optionally be able to pick a custom short link for their URL Links will expire after a standard default timespan Users should be able to specify the expiration time Non Functional Requirements Such a system should be highly available This is required because if our service is down all the URL redirections will start failing URL redirection should happen in real time with minimal latency Shortened links should not be guessable not predictable Extended Requirements Analytics e g how many times a redirection happened Our service should also be accessible through REST APIs by other services Capacity Estimation and ConstraintsOur system will be read heavy There will be lots of redirection requests compared to new URL shortenings Let s assume a ratio between read and write Traffic estimatesAssuming we will have M new URL shortenings per month with read write ratio we can expect B redirections during the same period M gt BWhat would be Queries Per Second QPS for our system New URLs shortenings per second million days hours seconds URLs sConsidering read write ratio URLs redirections per second will be URLs s K s Storage estimatesLet s assume we store every URL shortening request and associated shortened link for years Since we expect to have M new URLs every month the total number of objects we expect to store will be billion million years months billionLet s assume that each stored object will be approximately bytes just a ballpark estimate we will dig into it later We will need TB of total storage billion bytes TB Bandwidth estimatesFor write requests since we expect new URLs every second total incoming data for our service will be KB per second bytes KB sFor read requests since every second we expect K URLs redirections total outgoing data for our service would be MB per second K bytes MB s Memory estimatesIf we want to cache some of the hot URLs that are frequently accessed how much memory will we need to store them If we follow the rule meaning of URLs generate of traffic we would like to cache these hot URLs Since we have K requests per second we will be getting billion requests per day K seconds hours billionTo cache of these requests we will need GB of memory billion bytes GBOne thing to note here is that since there will be many duplicate requests of the same URL our actual memory usage will be less than GB System APIsWe can have SOAP or REST APIs to expose the functionality of our service Following could be the definitions of the APIs for creating and deleting URLs createURL api dev key original url custom alias None user name None expire date None Parameters api dev key string The API developer key of a registered account This will be used to among other things throttle users based on their allocated quota original url string Original URL to be shortened custom alias string Optional custom key for the URL user name string Optional user name to be used in the encoding expire date string Optional expiration date for the shortened URL Returns string A successful insertion returns the shortened URL otherwise it returns an error code deleteURL api dev key url key Where “url key is a string representing the shortened URL to be retrieved a successful deletion returns URL Removed How do we detect and prevent abuse A malicious user can put us out of business by consuming all URL keys in the current design To prevent abuse we can limit users via their api dev key Each api dev key can be limited to a certain number of URL creations and redirections per some time period which may be set to a different duration per developer key Database DesignA few observations about the nature of the data we will store We need to store billions of records Each object we store is small less than K There are no relationships between records ーother than storing which user created a URL Our service is read heavy Database Schema We would need two tables one for storing information about the URL mappings and one for the user s data who created the short link What kind of database should we use Since we anticipate storing billions of rows and we don t need to use relationships between objects ーa NoSQL store like DynamoDB Cassandra or Riak is a better choice A NoSQL choice would also be easier to scale Basic System Design and AlgorithmThe problem we are solving here is how to generate a short and unique key for a given URL In the TinyURL example in Section the shortened URL is “ The last eight characters of this URL constitute the short key we want to generate We ll explore two solutions here a Encoding actual URLWe can compute a unique hash e g MD or SHA etc of the given URL The hash can then be encoded for display This encoding could be base a z or base A Z a z and if we add and we can use Base encoding A reasonable question would be what should be the length of the short key or characters Using base encoding a letters long key would result in ⁶ billion possible strings Using base encoding an letters long key would result in ⁸ trillion possible strings With B unique strings let s assume six letter keys would suffice for our system If we use the MD algorithm as our hash function it will produce a bit hash value After base encoding we ll get a string having more than characters since each base character encodes bits of the hash value Now we only have space for or characters per short key how will we choose our key then We can take the first or letters for the key This could result in key duplication to resolve that we can choose some other characters out of the encoding string or swap some characters What are the different issues with our solution We have the following couple of problems with our encoding scheme If multiple users enter the same URL they can get the same shortened URL which is not acceptable What if parts of the URL are URL encoded e g and are identical except for the URL encoding Workaround for the issues We can append an increasing sequence number to each input URL to make it unique and then generate its hash We don t need to store this sequence number in the database Possible problems with this approach could be an ever increasing sequence number Can it overflow Appending an increasing sequence number will also impact the performance of the service Another solution could be to append the user id which should be unique to the input URL However if the user has not signed in we would have to ask the user to choose a uniqueness key Even after this if we have a conflict we have to keep generating a key until we get a unique one b Generating keys offlineWe can have a standalone Key Generation Service KGS that generates random six letter strings beforehand and stores them in a database let s call it key DB Whenever we want to shorten a URL we will take one of the already generated keys and use it This approach will make things quite simple and fast Not only are we not encoding the URL but we won t have to worry about duplications or collisions KGS will make sure all the keys inserted into key DB are uniqueCan concurrency cause problems As soon as a key is used it should be marked in the database to ensure that it is not used again If there are multiple servers reading keys concurrently we might get a scenario where two or more servers try to read the same key from the database How can we solve this concurrency problem Servers can use KGS to read mark keys in the database KGS can use two tables to store keys one for keys that are not used yet and one for all the used keys As soon as KGS gives keys to one of the servers it can move them to the used keys table KGS can always keep some keys in memory to quickly provide them whenever a server needs them For simplicity as soon as KGS loads some keys in memory it can move them to the used keys table This ensures each server gets unique keys If KGS dies before assigning all the loaded keys to some server we will be wasting those keys which could be acceptable given the huge number of keys we have KGS also has to make sure not to give the same key to multiple servers For that it must synchronize or get a lock on the data structure holding the keys before removing keys from it and giving them to a server What would be the key DB size With base encoding we can generate B unique six letters keys If we need one byte to store one alpha numeric character we can store all these keys in characters per key B unique keys GB Isn t KGS a single point of failure Yes it is To solve this we can have a standby replica of KGS Whenever the primary server dies the standby server can take over to generate and provide keys Can each app server cache some keys from key DB Yes this can surely speed things up Although in this case if the application server dies before consuming all the keys we will end up losing those keys This can be acceptable since we have B unique six letter keys How would we perform a key lookup We can look up the key in our database to get the full URL If it s present in the DB issue an “HTTP Redirect status back to the browser passing the stored URL in the “Location field of the request If that key is not present in our system issue an “HTTP Not Found status or redirect the user back to the homepage Should we impose size limits on custom aliases Our service supports custom aliases Users can pick any key they like but providing a custom alias is not mandatory However it is reasonable and often desirable to impose a size limit on a custom alias to ensure we have a consistent URL database Let s assume users can specify a maximum of characters per customer key as reflected in the above database schema Data Partitioning and ReplicationTo scale out our DB we need to partition it so that it can store information about billions of URLs Therefore we need to develop a partitioning scheme that would divide and store our data into different DB servers a Range Based PartitioningWe can store URLs in separate partitions based on the hash key s first letter Hence we save all the URL hash keys starting with the letter A and a in one partition save those that start with the letter B in another partition and so on This approach is called range based partitioning We can even combine certain less frequently occurring letters into one database partition Thus we should develop a static partitioning scheme to always store find a URL in a predictable manner The main problem with this approach is that it can lead to unbalanced DB servers For example we decide to put all URLs starting with the letter E into a DB partition but later we realize that we have too many URLs that start with the letter E b Hash Based PartitioningIn this scheme we take a hash of the object we are storing We then calculate which partition to use based upon the hash In our case we can take the hash of the key or the short link to determine the partition in which we store the data object Our hashing function will randomly distribute URLs into different partitions e g our hashing function can always map any key to a number between … This number would represent the partition in which we store our object This approach can still lead to overloaded partitions which can be solved using Consistent Hashing CacheWe can cache URLs that are frequently accessed We can use any off the shelf solution like Memcached which can store full URLs with their respective hashes Thus the application servers before hitting the backend storage can quickly check if the cache has the desired URL How much cache memory should we have We can start with of daily traffic and based on clients usage patterns we can adjust how many cache servers we need As estimated above we need GB of memory to cache of daily traffic Since a modern day server can have GB of memory we can easily fit all the cache into one machine Alternatively we can use a couple of smaller servers to store all these hot URLs Which cache eviction policy would best fit our needs When the cache is full and we want to replace a link with a newer hotter URL how would we choose Least Recently Used LRU can be a reasonable policy for our system Under this policy we discard the least recently used URL first We can use a Linked Hash Map or a similar data structure to store our URLs and Hashes which will also keep track of the URLs that have been accessed recently To further increase the efficiency we can replicate our caching servers to distribute the load between them How can each cache replica be updated Whenever there is a cache miss our servers would be hitting a backend database Whenever this happens we can update the cache and pass the new entry to all the cache replicas Each replica can update its cache by adding the new entry If a replica already has that entry it can simply ignore it Load Balancer LB We can add a Load balancing layer at three places in our system Between Clients and Application serversBetween Application Servers and database serversBetween Application Servers and Cache serversInitially we could use a simple Round Robin load balancer that distributes incoming requests equally among backend servers This LB is simple to implement and does not introduce any overhead Another benefit is that if a server is dead LB will take it out of the rotation and stop sending any traffic to it A problem with Round Robin LB is that we do not consider the server load As a result if a server is overloaded or slow the LB will not stop sending new requests to that server To handle this a more intelligent LB solution can be placed that periodically queries the backend server about its load and adjusts traffic based on that Purging or DB cleanupShould entries stick around forever or should they be purged If a user specified expiration time is reached what should happen to the link If we chose to continuously search for expired links to remove them it would put a lot of pressure on our database Instead we can slowly remove expired links and do a lazy cleanup Our service will ensure that only expired links will be deleted although some expired links can live longer but will never be returned to users Whenever a user tries to access an expired link we can delete the link and return an error to the user A separate Cleanup service can run periodically to remove expired links from our storage and cache This service should be very lightweight and scheduled to run only when the user traffic is expected to be low We can have a default expiration time for each link e g two years After removing an expired link we can put the key back in the key DB to be reused Should we remove links that haven t been visited in some length of time say six months This could be tricky Since storage is getting cheap we can decide to keep links forever Security and PermissionsCan users create private URLs or allow a particular set of users to access a URL We can store the permission level public private with each URL in the database We can also create a separate table to store UserIDs that have permission to see a specific URL If a user does not have permission and tries to access a URL we can send an error HTTP back Given that we are storing our data in a NoSQL wide column database like Cassandra the key for the table storing permissions would be the Hash or the KGS generated key The columns will store the UserIDs of those users that have permission to see the URL SummaryIn my experience every successful software developer has followed a systematic approach to solve a system design question during an interview The current interview process requires us to present a reasonable solution within minutes and the key to success is being organized during the system design interview Hopefully this step by step approach will help you stay on track during the interview Please take a look at Grokking the System Design Interview for more system design interview questions like Designing a file sharing service like Google Drive or Dropbox Designing a popular messaging service like Facebook Messenger Designing popular social network sites like Twitter or Facebook Designing a global video streaming service like Youtube Designing a global ride hailing service like Uber To learn software architecture and practice advanced system design interview questions take a look at Grokking the Advanced System Design Interview |
2022-01-02 01:25:11 |
ニュース |
BBC News - Home |
Gas prices: MPs and peers urge PM to act on energy bills |
https://www.bbc.co.uk/news/uk-59849731?at_medium=RSS&at_campaign=KARANGA
|
green |
2022-01-02 01:30:51 |
ニュース |
BBC News - Home |
Reigning world champion Price out of PDC darts |
https://www.bbc.co.uk/sport/darts/59848170?at_medium=RSS&at_campaign=KARANGA
|
michael |
2022-01-02 01:10:17 |
海外TECH |
reddit |
Aloha! Hau'oli Makahiki Hou! Guess The Meaning Of My Username For A Gold! |
https://www.reddit.com/r/AwardBonanza/comments/rtxzrh/aloha_hauoli_makahiki_hou_guess_the_meaning_of_my/
|
Aloha Hau x oli Makahiki Hou Guess The Meaning Of My Username For A Gold Aloha and Hau oli Makahiki Hou Happy New Year to you all Hope you survived last year as best you could and wish nothing but the best for all of you for This year has started off with a tremendous bang for me thanks to winning a challenge right here on r AwardBonanza so I would like to attempt to give back to the sub by trying my own simple challenge s Rules of Reddit and r AwardBonanza apply of course Mods have final say The challenge is simple The first user to correctly explain the meaning of my username wins one gold award It has to be exact so I ll provide one clue It s four words and all four words must be exact Good luck Contest ends when first persons guesses correctly EDIT I forgot to say you can guess as many times as you want and this is open to all users HINT GECKO is the nd word of the four x GECKO X X submitted by u gecko to r AwardBonanza link comments |
2022-01-02 01:25:27 |
コメント
コメントを投稿