Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
๐Ÿ˜Š
Hi

NaniteFactory

๐Ÿ˜Š
Hi
View GitHub Profile

๋ฌด๋ฃŒ MongoDB ์„œ๋ฒ„ ๋งŒ๋“ค๊ธฐ

๋ฐฉ๋ฒ•์€ 2๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

  1. MongoDB Atlas ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค ์ด์šฉ
    • MongoDB Atlas: https://cloud.mongodb.com/
    • ๊ฑฐ์˜ SaaS์ž„. ์ธํ”„๋ผ๋ฅผ ์ „ํ˜€ ์‹ ๊ฒฝ ์“ฐ์ง€ ์•Š๊ณ  ํŽธํ•˜๊ฒŒ ์“ธ ์ˆ˜ ์žˆ๋‹ค. ํšŒ์› ๊ฐ€์ž…ํ•˜๊ณ  ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ๋ชจ๋“  ๊ณผ์ •์ด ์›น GUI๋กœ ์•ˆ๋‚ด๋œ๋‹ค.
    • 512GB๊นŒ์ง€ ๋ฌด๋ฃŒ ์ด์šฉ ๊ฐ€๋Šฅํ•˜๊ณ  ์œ ๋ฃŒ ์ตœ์†Œ ํฌ๊ธฐ์ธ 2GB๋กœ ํ™•์žฅํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋งค๋‹ฌ ๋ฏธํ™” 9๋ถˆ ๊ฒฐ์ œ ํ•„์š”ํ•˜๋‹ค. [์ถœ์ฒ˜]
  2. IaaS ์ปดํ“จํŒ… ํด๋ผ์šฐ๋“œ
    • [OCI]: ๊ฐœ์ธ์ •๋ณด๋ฅผ ์ž”๋œฉ ๊ฐˆ์ทจํ•˜๊ณ  ํšŒ์›๊ฐ€์ž…์ด ์•ˆ ๋๋‹ค.

pprof ์‚ฌ์šฉ๋ฒ•

1. pprof์˜ ๊ตฌ๋ถ„

  1. go tool pprof ํ”„๋กœ๊ทธ๋žจ:
    • pprof ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ๋ณด์—ฌ ์ฃผ๋Š” pprof ๋ฐ”์ด๋„ˆ๋ฆฌ๋‹ค.
  2. runtime/pprof ํŒจํ‚ค์ง€:
    • Go ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ๋ถ€ํ„ฐ pprof ๋ฐ์ดํ„ฐ๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋‚ด๋ณด๋‚ด๋Š” ์ผ์„ ํ•˜๋Š” ํŒจํ‚ค์ง€๋‹ค.
  3. net/http/pprof ํŒจํ‚ค์ง€:
    • runtime/pprof ํŒจํ‚ค์ง€๊ฐ€ ํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ (ServeHTTP๋กœ) ์›น์œผ๋กœ ๋‚ด๋ณด๋‚ด๊ฑฐ๋‚˜ ํ”„๋กœ๊ทธ๋žจ์˜ pprof ๋ฐ์ดํ„ฐ๋ฅผ ๋ถ„์„ํ•˜์—ฌ ์›น ์ธํ„ฐํŽ˜์ด์Šค๋กœ ๋ณด์—ฌ ์ฃผ๋Š” ์ผ์„ ํ•˜๋Š” ํŒจํ‚ค์ง€๋‹ค.
@NaniteFactory
NaniteFactory / processclear.go
Created September 9, 2020 11:21
kill all processes in windows
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os/exec"
"strconv"
"strings"
@NaniteFactory
NaniteFactory / fileserver.go
Last active September 4, 2020 11:20
fileserver written in go
package main
import (
"flag"
"log"
"net/http"
)
var (
listen = flag.String("listen", ":8080", "listen address")
@NaniteFactory
NaniteFactory / shard.go
Created June 8, 2020 03:37
Discordgo sharding
package shard
import (
"errors"
"fmt"
"strconv"
"sync"
"github.com/bwmarrin/discordgo"
)
@NaniteFactory
NaniteFactory / fullscreenshot.go
Created May 17, 2020 07:13
chromedp full screen shot
func FullScreenshot(quality int64, result *[]byte) chromedp.Action {
return chromedp.ActionFunc(func(ctx context.Context) error {
// get layout metrics
_, _, contentSize, err := page.GetLayoutMetrics().Do(ctx)
if err != nil {
return err
}
width, height := int64(math.Ceil(contentSize.Width)), int64(math.Ceil(contentSize.Height))
@NaniteFactory
NaniteFactory / nested_defer.go
Created December 6, 2019 08:24
Nested function calls in a defer statement.
package main
import "log"
func foo1(n int) int {
log.Println("foo1", n)
return n
}
func foo2(n int) int {
log.Println("foo2", n)
@NaniteFactory
NaniteFactory / go-sqlite3.go
Created November 30, 2019 17:38
go sqlite tutorial example
package main
import (
"database/sql"
"log"
_ "github.com/mattn/go-sqlite3"
)
func main() {

chromedp ๊ตฌ์„ฑ์š”์†Œ ์ •๋ฆฌ ์š”์•ฝ

2019๋…„ 11์›” 30์ผ

chromedp ํŒจํ‚ค์ง€์˜ ์ „์ฒด๋ฅผ ํŒŒ์•…ํ•˜๊ธฐ ์œ„ํ•ด ํ•ต์‹ฌ ํƒ€์ž…์„ ์ค‘์‹ฌ์œผ๋กœ ์„ค๋ช… ์ •๋ฆฌ

ํ๋ฆ„์„ ํฐ ์ค„๊ธฐ์—์„œ ์‹œ์ž‘ํ•˜์—ฌ ์ž‘์€ ์ค„๊ธฐ์™€ ๋ง๋‹จ์— ์ด๋ฅด๋Š” ์ˆœ์„œ๋กœ ๊ตฌ์„ฑํ•จ


@NaniteFactory
NaniteFactory / fullscreenshot.go
Created October 21, 2019 06:55
chromedp screenshot example
package main
import (
"context"
"io/ioutil"
"log"
"math"
"time"
"github.com/chromedp/cdproto/emulation"